Solved

How can I rollback a update in SQL Server 2010?

Posted on 2014-01-22
4
314 Views
Last Modified: 2014-01-24
I am new to SQL Server.
Whe update few rows in SQL Server
Eg:
UPDATE EMP
SET State='Tx' WHERE ID=2

How do I rollback the update?
0
Comment
Question by:RajG1978
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 25

Assisted Solution

by:Lee Savidge
Lee Savidge earned 100 total points
ID: 39800445
You need to put it into a transaction

begin tran
UPDATE EMP
SET State='Tx' WHERE ID=2
rollback tran

Open in new window

0
 
LVL 18

Expert Comment

by:x-men
ID: 39800446
restore the database.

rollback ocurres when the transaction is not completed.
0
 
LVL 25

Expert Comment

by:Lee Savidge
ID: 39800465
Of course, I'm assuming you haven't issued the command and wish to undo it? If so, then restore the database from the backup you would have made before doing an update...

If not, then you must live with your update.
0
 
LVL 16

Accepted Solution

by:
Surendra Nath earned 400 total points
ID: 39800466
SQL Server is not Oracle...

In oracle by default the statements will not be commited to the database, so you can issue rollback whenever you want after all the changes that you did.

But SQL Server by default will commit the update to the database as soon as the update finished its job....

So, if you want to rollback such updates you have to put them in an external transaction

BEGIN TRAN
--UPDATE


But if you have accidentally did this update and looking for a way out...
The only option is to do a restore a backup file
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question