tempo1
Programmer
- Feb 20, 2007
- 118
Hi everyone
i write a dynamic sql query in which a parameter is involoved:
and i dont know how to get rid of the following error message i get
i write a dynamic sql query in which a parameter is involoved:
Code:
/*drop table table1*/
DECLARE @param1 VARCHAR(10)
SET @param1='aa'
DECLARE @dynamic VARCHAR(1000)
SET @dynamic=
'
SELECT '
+ '@param1' + ' "param"
INTO
table1
'
print(@dynamic)
exec(@dynamic)
go
Could anyone tell me what is wrong with that querry ?Thanks.Server: Msg 137, Level 15, State 2, Line 2
Must declare the variable '@param1'.