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 |
|
phrankbooth
Posting Yak Master
162 Posts |
Posted - 2009-01-27 : 11:56:55
|
| Hi,I have this table:Col1|Col2AAAA|1111BBBB|2222CCCC|3333DDDD|4444I want to Update Col2 of rows BBBB and CCCC.So that my result is:Col1|Col2AAAA|1111BBBB|0000CCCC|9999DDDD|4444What would the single Update statement be for this?Thanks!--PhB |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-01-27 : 11:59:26
|
just use UPDATE tableSET Col2=CASE WHEN Col1 = 'BBBB' THEN '0000' ELSE '9999' ENDWHERE Col1 IN ('BBBB','CCCC') |
 |
|
|
phrankbooth
Posting Yak Master
162 Posts |
Posted - 2009-01-27 : 12:17:29
|
| Thanks for the quick reply!--PhB |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-01-27 : 12:20:39
|
| welcome |
 |
|
|
|
|
|