0

I'm using MS SQL Server 2005 enterprise edition. I executed an update query to get affect a record in a row and a column.

update HS_SM_USERACCOUNT 
set ACCOUNTPOLICYTYPE=1  
where EMP_NUMBER='000540' and USERID='03510410@' 

Earlier the column called ACCOUNTPOLICYTYPE is holding value 1 for that particular condition in WHERE clause. Now I want to get the previous state without executing Update Query again.

Will ROLLBACK help me? Please help me on this.

Alex R.
  • 4,664
  • 4
  • 30
  • 40
  • So, you want to set accounttype to 0 or another value that is not 1? You can't do that without executing an UPDATE statement or restoring a backup from before you ran your UPDATE. If you want to do a ROLLBACK you must first have executed a BEGIN TRANSACTION statement. – mortb Sep 12 '12 at 07:35

2 Answers2

0

No. It's changed. If you want to know what it was, restore from backup

podiluska
  • 50,950
  • 7
  • 98
  • 104
0

Unless you executed the above query within the scope of a TRANSACTION - i.e. within BEGIN TRAN / COMMIT / ROLLBACK TRAN block, the ROLLBACK command is going to be of no use.

There is nothing you can do to get back the state that you updated with the above statement in such a situation except RESTORE an OLD backup of that table data

Jagmag
  • 10,283
  • 1
  • 34
  • 58