trpnbillie
Programmer
Hi Everyone!
Does anybody know how to assign a variable to a dynamic sql statement result?
The code below works until I reach the last line where I try to assign my variable... I am very unsuccessful!
---START
DECLARE @Table nvarchar(100)
SET @Table = 'TestTable'
DECLARE @SQL nvarchar(1000)
SET @SQL = 'select Status from ' + @Table + ' where ID = 1'
exec (@SQL)
DECLARE @StatusResult = exec (@SQL) --- this line fails
---END
Many Thanks for your insight!!!!
Does anybody know how to assign a variable to a dynamic sql statement result?
The code below works until I reach the last line where I try to assign my variable... I am very unsuccessful!
---START
DECLARE @Table nvarchar(100)
SET @Table = 'TestTable'
DECLARE @SQL nvarchar(1000)
SET @SQL = 'select Status from ' + @Table + ' where ID = 1'
exec (@SQL)
DECLARE @StatusResult = exec (@SQL) --- this line fails
---END
Many Thanks for your insight!!!!