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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Update problem for multiple record

Author  Topic 

Indrajit
Starting Member

11 Posts

Posted - 2011-03-07 : 08:34:24
Hi All
I m trying to update multiple record at at a time through IN key word but it is not working?
Please help

IndrajitDasgupta

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2011-03-07 : 08:45:17
What does the update statement look like and what is the error message?

- Lumbago
My blog-> http://thefirstsql.com/2011/02/07/regular-expressions-advanced-string-matching-and-new-split-function-sql-server-2008-r2/
Go to Top of Page

Indrajit
Starting Member

11 Posts

Posted - 2011-03-07 : 08:57:06
quote:
Originally posted by Lumbago

What does the update statement look like and what is the error message?

- Lumbago
My blog-> http://thefirstsql.com/2011/02/07/regular-expressions-advanced-string-matching-and-new-split-function-sql-server-2008-r2/


UPDATE CNMPNT SET
CUSTOMER_ALPHA=@ChangeAlphaPoiner

WHERE
CUSTOMER_ALPHA=@aplhaPointer AND
ltrim(Rtrim(replace(CUSTOMER_ID,char(0),''))) IN (@CustomerIDs)

here I m sending value from front end to @CustomerIDs but is not working

IndrajitDasgupta
Go to Top of Page

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2011-03-07 : 10:08:37
I assume that @CustomerId has comma-separated values. While it would have been a very nice feature to be able to do this, you cannot use a variable in that context as you have done. People do various things to get around this:
a) you can split the comma-separated values into a table variable and then join on that table. You can find examples of how split comma-separated values if you search this site.
b) Do something along these lines:

and
','+@CustomerIds+',' like '%,'+CUSTOMER_ID+',%'
Go to Top of Page
   

- Advertisement -