ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip       Ask Questions on ANYTHING, that arise in your Daily Life at     FORUM9.COM
Google
 
Categories  >>  Software  >>  Databases  >>  SQL Server
 
 


 

 
 Oracle interview questions  Oracle Interview Questions
 SQL Server interview questions  SQL Server Interview Questions
 MS Access interview questions  MS Access Interview Questions
 MySQL interview questions  MySQL Interview Questions
 Postgre interview questions  Postgre Interview Questions
 Sybase interview questions  Sybase Interview Questions
 DB Architecture interview questions  DB Architecture Interview Questions
 DB Administration interview questions  DB Administration Interview Questions
 DB Development interview questions  DB Development Interview Questions
 SQL PLSQL interview questions  SQL PLSQL Interview Questions
 Databases AllOther interview questions  Databases AllOther Interview Questions
Question
How do we rollback the table data in SQL Server
 Question Submitted By :: Bsatish
I also faced this Question!!     Rank Answer Posted By  
 
  Re: How do we rollback the table data in SQL Server
Answer
# 1
Actually rollbacks are automatic. MS SQL Server is fully 
ACID compliant. 

ROLLBACK { TRAN | TRANSACTION } 
     [ transaction_name | @tran_name_variable
     | savepoint_name | @savepoint_variable ] 
[ ; ]

Arguments:
transaction_name 
Is the name assigned to the transaction on BEGIN 
TRANSACTION. transaction_name must conform to the rules for 
identifiers, but only the first 32 characters of the 
transaction name are used. When nesting transactions, 
transaction_name must be the name from the outermost BEGIN 
TRANSACTION statement.

@ tran_name_variable 
Is the name of a user-defined variable containing a valid 
transaction name. The variable must be declared with a 
char, varchar, nchar, or nvarchar data type.

savepoint_name 
Is savepoint_name from a SAVE TRANSACTION statement. 
savepoint_name must conform to the rules for identifiers. 
Use savepoint_name when a conditional rollback should 
affect only part of the transaction.

@ savepoint_variable 
Is name of a user-defined variable containing a valid 
savepoint name. The variable must be declared with a char, 
varchar, nchar, or nvarchar data type.

 Remarks 
ROLLBACK TRANSACTION erases all data modifications made 
from the start of the transaction or to a savepoint. It 
also frees resources held by the transaction.

ROLLBACK TRANSACTION without a savepoint_name or 
transaction_name rolls back to the beginning of the 
transaction. When nesting transactions, this same statement 
rolls back all inner transactions to the outermost BEGIN 
TRANSACTION statement. In both cases, ROLLBACK TRANSACTION 
decrements the @@TRANCOUNT system function to 0. ROLLBACK 
TRANSACTION savepoint_name does not decrement @@TRANCOUNT.

A ROLLBACK TRANSACTION statement specifying a 
savepoint_name releases any locks acquired beyond the 
savepoint, with the exception of escalations and 
conversions. These locks are not released, and they are not 
converted back to their previous lock mode.

ROLLBACK TRANSACTION cannot reference a savepoint_name in 
distributed transactions started either explicitly with 
BEGIN DISTRIBUTED TRANSACTION or escalated from a local 
transaction.

A transaction cannot be rolled back after a COMMIT 
TRANSACTION statement is executed.

Within a transaction, duplicate savepoint names are 
allowed, but a ROLLBACK TRANSACTION using the duplicate 
savepoint name rolls back only to the most recent SAVE 
TRANSACTION using that savepoint name.

In stored procedures, ROLLBACK TRANSACTION statements 
without a savepoint_name or transaction_name roll back all 
statements to the outermost BEGIN TRANSACTION. A ROLLBACK 
TRANSACTION statement in a stored procedure that causes 
@@TRANCOUNT to have a different value when the stored 
procedure completes than the @@TRANCOUNT value when the 
stored procedure was called produces an informational 
message. This message does not affect subsequent processing.
 
Is This Answer Correct ?    1 Yes 2 No
Arunyadav007
 
  Re: How do we rollback the table data in SQL Server
Answer
# 2
begin transaction
save transcation t
delete from tablename where id=2
select * from tablename
------------------------------------------------------
the value id=2 will be deleted in the tablename
-------------------------------------------------------
rollback transcation t
select * from tablename
---------------------------------------------------------
if u give rollback the deleted values will be seen again
 
Is This Answer Correct ?    8 Yes 2 No
Elumalai.k
 
 
 
  Re: How do we rollback the table data in SQL Server
Answer
# 3
Above code spelling are wrong on save Transaction
correct code are below which is executeable 

begin transaction
save transaction t
delete from tablename where id=2
select * from tablename
------------------------------------------------------
the value id=2 will be deleted in the tablename
-------------------------------------------------------
rollback transaction t
select * from tablename
 
Is This Answer Correct ?    1 Yes 0 No
Umesh Roy
 

 
 
 
Other SQL Server Interview Questions
 
  Question Asked @ Answers
 
Can anybody explain me cold backup and hot backup? TCS3
Which is better in performance - CONSTRAINT or TRIGGER over a column which restricts say an input of particular value in a column of a table? Accenture3
MULTICAST DELEGATES IN C#.NET WITH REAL TIME EXAMPLE IBM1
There is a trigger defined for INSERT operations on a table, in an OLTP system. The trigger is written to instantiate a COM object and pass the newly insterted rows to it for some custom processing. What do you think of this implementation? Can this be implemented better?  1
what is difference between having and where clause ?  2
What is the difference between windows authentication and sql server authentication HCL4
i want only duplicates rows from coloumn ex. emp_id(colomn name)1,1,2,3,3,4,5,5. so i want only duplicates no. iFlex2
How to restart SQL Server in single user mode? How to start SQL Server in minimal configuration mode?  1
1.How to check the backup file details if we do not have access to that folder 2.how to check the backup file size without connecting to the folder IBM1
HOW TO FIND THE EMPLOYEE DETAILS WHO ARE GETTING SAME SALARY IN EMP TABLE TCS16
What is the difference between local table and global table Polaris1
IN Vs OR operator which is best to use sql server.  3
Hi SQL gurus, i am working for an MNC... My team is having a problem in sql server. when user slects date prompts from jan 1st to april 30, it should display all months data like : jan aa feb bb mar cc but when it comes to april its taking data like : jan aa feb bb mar cc apr dd...and so on means its taking data again from jan to april which we dont want. we want the data only april month as we are getting jan, feb and mar... can any one write the code to relsove the issue please would be greatful if you can send to shiva_sans@yahoo.co.in and also please send your email also ...so that we will be in touch for any kind of queries ... Thanks a lot in Advance !!!  1
How to Get the last identity value used  4
How to write a script for upate the data in prod , i have 50000 row are there TCS2
What is the basic functions for master, msdb, tempdb databases? CSC2
Which is best Subquery (or) joins in sql server? explain why  2
How To Change Column Ordinal Position in SQL Server 2005 using Query i.e I Want To Add Column at Particular Ordinal Position in SQL Server 2005  2
What is the difference between temp table and table variable? Microsoft4
How the data stores in a page?  1
 
For more SQL Server Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com