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 |
|
PanzerAttack
Yak Posting Veteran
71 Posts |
Posted - 2011-08-15 : 06:11:01
|
| I'm about to change a number of records as customer 586045 has moved from 2774000 to 3743011 in my history file.Before I post, does this look right? DS Reporting Database is the database name.UPDATE [DS Reporting Database]SET CL3 = replace(CL3, '2774000', '3743011')WHERE CL4 = '586045'SET CL3 = replace(CL3, '00/01/GB11/2774000', '00/01/GB11/3743011')WHERE CL4 = '00/01/GB11/586045'SET CL3 = replace(CL3, '00/02/GB11/2774000', '00/02/GB11/3743011')WHERE CL4 = '00/02/GB11/586045'SET CL3 = replace(CL3, '00/05/GB11/2774000', '00/05/GB11/3743011')WHERE CL4 = '00/05/GB11/586045' |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-08-15 : 06:31:58
|
if you are not sure, always make a backup of your database before proceedyou can't have multiple SET & WHERE clause in the same query. The correct update syntax isUPDATE < table name >SET . . .WHERE < condition > KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
PanzerAttack
Yak Posting Veteran
71 Posts |
Posted - 2011-08-15 : 06:48:48
|
| Thanks that was very scary but seems to have worked like a charm. |
 |
|
|
|
|
|