I am writing a procedure which needs table name and col. name to be passed in as variables. I am using dynamic SQL (i dont know if there is any other way). My problem is that when I use the following code, I get an error -
'insert into '+@variable1+
' select * from #table2 where column1 = 'a' and column2 = '+@variable2
error: Invalid column @variable2.
Can anyone suggest the answer for this? - Thanks in advance.