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.
| Author |
Topic |
|
csphard
Posting Yak Master
113 Posts |
Posted - 2002-01-29 : 10:02:45
|
| 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 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2002-01-29 : 12:40:54
|
| The CASE statement should do it:UPDATE tableSET testdate=CASE testcheckWHEN 'X' THEN '01/01/2002'WHEN 'Y' THEN '01/15/2002'WHEN 'o' THEN '01/20/2002' ENDWHERE testcheck IN ('X','Y','o')You can check Books Online for more information on the CASE statement, or search here on SQL Team for "CASE". There's a number of examples that show how handy CASE is. |
 |
|
|
|
|
|