sarika_patalay
asked on
SQL 2005, error with Dynamic SQL
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.
'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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.