Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to update multiple rows in MS SQL?

Status
Not open for further replies.

lele123

Programmer
Oct 9, 2009
2
US
My table looks like this:

c1 c2 c3
a 1 2000
a 2 2001
a 3 3000
a 4 3001
a 5 3002


Step 1: delete rows where c3 = 2000, 2001

Delete table where c3 like '2___'

Step 2: change 3000 to 2000, 3001 to 2001, 3002 to 2002, and so forth

I'm stuck here. I'd appreciate any pointers or examples using MS SQL.
 
delete from tablename where c3 in (2000,2001)
or
delete from tablename where c3 < 3000

etc...

update tablename set c3 = c3 - 1000
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top