I have concatenated a long Select Statement and assigned it to a variable. (i.e.)
@a = Select * from foo ---Obviously mine is much more robust
How do I execute @a to actually Select * from foo
I have concatenated a long Select Statement and assigned it to a variable. (i.e.)
@a = Select * from foo ---Obviously mine is much more robust
How do I execute @a to actually Select * from foo
Getting a Variable that has a SELECT statement to Return Results
Latif1
cicorias
You can use
exec (@a)
If @a is nvarchar rather than varchar you can also do this
exec sp_executesql @a