| Author |
Topic |
|
ggarza75
Yak Posting Veteran
50 Posts |
Posted - 2011-03-01 : 15:40:06
|
| I've searched and searched, but couldnt find anything so I'm here to ask. When you make a change in the DB by an update statement and the realize you made a mistake, is there a way to rollback/undo what you did?I only ask because a person on our team updated a field, but to all the records in the database. Person forgot to add the WHERE clause. We're all good because we have backups, but wanted to know if we could roll back that change with some kind of ROLLBACK code.Thanks. |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
ggarza75
Yak Posting Veteran
50 Posts |
Posted - 2011-03-01 : 15:51:37
|
| It was just a plain update statement like below and nothing else. Will what you provided above work? Thanks.Update Table_nameSet col = 'xx' |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
ggarza75
Yak Posting Veteran
50 Posts |
Posted - 2011-03-01 : 16:14:41
|
| Got it thanks. |
 |
|
|
yukiever
Starting Member
13 Posts |
Posted - 2011-03-01 : 16:32:01
|
quote: Originally posted by ggarza75 It was just a plain update statement like below and nothing else. Will what you provided above work? Thanks.Update Table_nameSet col = 'xx'
You cannot undo this..? T.TI did the same mistake.........1 minute ago.I also forgot the WHERE statement and I am in trouble...Heres my code:UPDATE test_table31 SET weather='Sunny'Should be added (WHERE forecast='Sunny')Plz helpthis is SQL Server 2008 (I am using MS Server Management Studio) |
 |
|
|
ggarza75
Yak Posting Veteran
50 Posts |
Posted - 2011-03-01 : 16:40:50
|
| Since you did exactly what my team member did, you'll need to get your old values from the most recent backup. Thats what we had to do. |
 |
|
|
yukiever
Starting Member
13 Posts |
Posted - 2011-03-01 : 17:31:05
|
quote: Originally posted by ggarza75 Since you did exactly what my team member did, you'll need to get your old values from the most recent backup. Thats what we had to do.
Thanks. I didn't have backup so I created the table again... |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
|