Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Update Multiple Rows using ingle query
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

rwaldron
Posting Yak Master

131 Posts

Posted - 04/28/2014 :  07:04:34  Show Profile  Reply with Quote
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 - 04/28/2014 :  07:52:04  Show Profile  Reply with Quote
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)

Singapore
17689 Posts

Posted - 04/28/2014 :  08:05:25  Show Profile  Reply with Quote
OR

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



KH
Time is always against us

Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.04 seconds. Powered By: Snitz Forums 2000