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 |
|
pbs1313
Starting Member
2 Posts |
Posted - 2004-10-19 : 18:44:29
|
| Hi. I need some help w/ Dynamic SQL for a stored procedure I need to produce. I'm a web dev, and not a DBA, but this task has fallen to me for this project anyway. I'm trying to update some values in a table and can't get this to work. Ultimately, I will pass in a comma delimited string for @EntryIDList and an int for @CategoryID. declare @CategoryID int set @CategoryID = 1 declare @EntryIDList varchar(250) set @EntryIDList= '1006,1009,1034' declare @finalist int set @finalist = 10 update dbo.ContestEntry set ContestStatusID = @finalistfrom dbo.ContestEntry ejoin dbo.EntryVoteSummery son e.EntryID = s.EntryIDwhere e.CategoryID = @CategoryIDand e.entryid in @EntryIDListWhat can I do to fix this error?: "Line 13: Incorrect syntax near '@EntryIDList'."Thanks. |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2004-10-19 : 18:54:56
|
| http://www.sqlteam.com/item.asp?ItemID=11499Tara |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2004-10-19 : 18:57:18
|
| seehttp://www.nigelrivett.net/ParseCSVString.htmljoin dbo.fn_ParseCSVString(@EntryIDList, ',') csvon e.entryid = convert(int,csv.s)orand ',' + @EntryIDList + ',' like '%,' + convert(varchar(20),e.entryid) + ',%'==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|
|
|