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 Statement help

Author  Topic 

milo145
Starting Member

3 Posts

Posted - 2009-08-19 : 13:20:40
The following runs fine,,,,,,,but

UPDATE Contacts
SET Type_ID = '5770'
WHERE Mailing_List_IDs = ',5520,'

It updates when only ,5520, is found. What is the correct sytax if other items are in Mailing_List_IDs?

Example would be if ,5520,5530,5540, were found in the column or any combination?

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2009-08-19 : 13:24:16
you mean:
where Mailing_List_IDs in (5520,5530,5540)

Be One with the Optimizer
TG
Go to Top of Page

milo145
Starting Member

3 Posts

Posted - 2009-08-19 : 13:29:22
No if there happened to be other items in the column. It ran. Updated only when it found 5520 but it did not update when other items where found in the column like 5530,5540,or whatever
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2009-08-19 : 13:33:25
Oh - You main the column, [Mailing_List_IDs] contains a concatenated list of IDs? That is not a good design but you could use:

where Mailing_List_IDs like '%,5530,%'

Be One with the Optimizer
TG
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-08-19 : 13:33:26
try this:
where ','+Mailing_List_IDs+',' like '%,5520,%'


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

milo145
Starting Member

3 Posts

Posted - 2009-08-19 : 13:40:56
Webfred rocks......... thanks worked like a charm
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-08-19 : 13:43:52
welcome


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -