| ID | Name | Age | Department | |
| 1 | Ashish | 25 | DotNet | |
| 2 | Mohit | 26 |
| |
| 3 | Amit | 24 |
|
we have a table name - Employee & ID is auto genrate. suppose i want to delete the record with this query.
Delete from Employee Where ID=2
but after delete the record i want to again rollback how is it posible . plz explain me with easy way (i want to rollback )
and what is the diff b/w rollback & Commit


Gaurav GuptaRank #123 · 17.8K reputationPosted Apr 11, 2013, 11:37 PM EDT
For Example you can write the query like this....
begin tran
Delete from Employee Where ID=2
Rollback tran
You can also read the following Blog on C-SharpCorner
http://www.c-sharpcorner.com/Blogs/5318/
Ashish Saxena5 reputationPosted Apr 11, 2013, 11:51 PM EDT
Gaurav GuptaRank #123 · 17.8K reputationPosted Apr 12, 2013, 2:13 AM EDT
http://raresql.com/2011/10/22/how-to-recover-deleted-data-from-sql-sever/
Shankar MRank #874 · 2.5K reputationPosted May 6, 2013, 9:01 PM EDT
You can use Explicit Transaction to do such changes..
Explicit Transactions are nothing but where you explicitly call the start and end of the Transaction..
To Start a Transaction we specify,
BEGIN TRANSACTION
In case of Error, we specify
ROLLBACK TRANSACTION.
To End a Transaction successfully we issue,
COMMIT TRANSACTION
While using Explicit Transactions, the transaction is done as a whole or none of the Transaction is committed.
Rasadul Alam Rashed46 reputationPosted May 16, 2013, 12:19 AM EDT
You can use this: http://cybarlab.com/transactions-in-sql-server
ashleyturnier18 reputationPosted Oct 10, 2013, 9:41 PM EDT