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 2000 Forums
 Transact-SQL (2000)
 updating multiple records

Author  Topic 

csphard
Posting Yak Master

113 Posts

Posted - 2002-01-29 : 10:02:52
Can you update several records using a single update statement with multiple sets and wheres

example

update table set testdate = '01/01/2002' where testcheck = 'X',
set testdate = '01/15/2002' where testcheck = 'Y',
set testdate = '01/20/2002' where testcheck = 'o'

would this work using sql2000


Nazim
A custom title

1408 Posts

Posted - 2002-01-29 : 10:13:28
you can use Case to do it.


update table set testdate = Case testcheck
When 'X' then '01/15/2002'
When 'Y' then '01/15/2002'
When 'Z' then '01/20/2002'
end

HTH

--------------------------------------------------------------
Dont Tell God how big your Problem is , Tell the Problem how Big your God is

Edited by - Nazim on 01/29/2002 10:14:37
Go to Top of Page
   

- Advertisement -