Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
dasu
Posting Yak Master
104 Posts |
Posted - 2004-09-08 : 09:32:43
|
| i want some help for dynamic sqlthis is my stored procedurealter proc del @jid int as declare @t varchar(30), @a varchar(1000)set @a='select @t = feed_cd from t_cbs_job_ctrl where job_id='+cast (@jid as varchar(30))print(@a) execute(@a) print (@t)iam executing like thisexec del 5iam getting following errors select @t = feed_cd from t_cbs_job_ctrl where job_id=5Server: Msg 137, Level 15, State 1, Line 1please suggest me the solutionregardsdasu.g |
|
|
timmy
Master Smack Fu Yak Hacker
1242 Posts |
Posted - 2004-09-08 : 09:42:31
|
| You don't need to use dynamic sql for this. |
 |
|
|
Scott
Posting Yak Master
145 Posts |
Posted - 2004-09-08 : 09:51:37
|
Change it to the following:alter proc del @jid int, @t varchar(30) OUTPUTasselect @t = feed_cd from t_cbs_job_ctrl where job_id = cast(@jid as varchar(30)) You only need to use dynamic SQL when you need to dynamicly set the table name or field name.Scott |
 |
|
|
|
|
|