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 |
|
paul.rowling
Yak Posting Veteran
81 Posts |
Posted - 2003-10-16 : 09:42:49
|
| Hi,I need to update multiple columns (37 in total) in a table at the same time based on different criteria.The table is called therapies and I want it to work as follows:update therapies set field1 = 'blah'where .........Xand update therapiesset field2 = 'blahh'where .........Xand update therapiesset field3 = 'blahhh'where .........XHow do I write this in sql, please note that the where statements may need to include subqueries.Any info will be greatly appreciated.CheersPaul |
|
|
Merkin
Funky Drop Bear Fearing SQL Dude!
4970 Posts |
Posted - 2003-10-16 : 09:46:39
|
| Maybe something like :UPDATE TherapiesSET Field1 = CASE WHEN (condition) THEN 'blah' ELSE Field1 END,Field2 = CASE WHEN (condition) THEN 'blah' ELSE Field2 ENDDoes that work for you ?Damian |
 |
|
|
paul.rowling
Yak Posting Veteran
81 Posts |
Posted - 2003-10-16 : 10:26:28
|
| Hi Merkin,Works excellent, thanks alot!!CheersPaul |
 |
|
|
|
|
|