TSQL: Variable scope and EXEC()
- by Joel
declare @test varchar(20)
set @test = 'VALUE'
exec('
select '+@test+'
')
This returns:
Invalid column name 'VALUE'.
Is there an alternate method to display the variable value on the select statement?