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 |
pssumesh2003
Starting Member
35 Posts |
Posted - 2010-01-21 : 05:14:01
|
Hi every body
i am working using vs2005 and sql server 2005. In my project i want to execute a query like update tbltrans set Amount = amount+1000 where id in (100,105,210,225).
i want to pass that Ids through my program . i try like declare @parameters update tbltrans set Amount = amount+1000 where id in @parameters
but get a message cannot convert ---
how it possible please help me? |
|
Kristen
Test
22859 Posts |
Posted - 2010-01-21 : 05:18:55
|
You can't use a parameter for IN(...)
You can use a SPLIT function to convert @parameters into a "table":
update U set Amount = amount+1000 FROM tbltrans AS U JOIN dbo.MySplitFunction(@parameters) AS S on S.SplitID = U.id
|
 |
|
Kristen
Test
22859 Posts |
|
pssumesh2003
Starting Member
35 Posts |
Posted - 2010-01-21 : 06:58:13
|
Thank u |
 |
|
|
|
|