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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Update Multiple Rows using ingle query

Author  Topic 

rwaldron
Posting Yak Master

131 Posts

Posted - 2014-04-28 : 07:04:34
Hiya Guys.
I have a table calld table1 containing rows called satus,code etc
Is there a way to update status to 'Y' where each code exists in the table.I have about 100 codes that I want their status's set to Y in a single query

Is it something like below using OR ?
update table1 set status='Y' where code ='1234' or code ='5678' or code ='1122'

rwaldron
Posting Yak Master

131 Posts

Posted - 2014-04-28 : 07:52:04
Yep it is
update table1 set status='Y' where code ='1234' or code ='5678' or code ='1122'
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2014-04-28 : 08:05:25
OR

update table1 set status='Y' where code in ('1234' , '5678' , '1122')



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -