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   SiteMap shows list of All Categories in this site.
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 ?    7 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
 
What value could be assigned to Varchar Type?  3
what is for foreign key ?? Sabic3
What is normalization and its forms? Challenger-Financial3
Rate yourself in .NET and SQL ? Cognizent1
What is a function? Give some example?  2
HOW TO RENAME A COLUMN NAME  2
WRITE A FUNCTION TO DISPLAY THE OUTPUT OF AN EXISTING TABLE RANGE LIKE COMMAM SEPERATED VALUES LIKE RANGE1,RANGE2,... TVS2
What are the steps you will take to improve performance of a poor performing query? HCL1
What is ACID Property of Transaction?  4
Define candidate key, alternate key, composite key.  9
Can you create UNIQUE and PRIMARY KEY constraints on computed columns in SQL Server 2000? Infosys1
What is The Use Of TIMESTAMP DataType in SQL Server 2005?  3
what are the new features of sql server 2005? HP5
wt is mean by acid property? i know it is atomocity,consistency,isolation and durabulaty but wt is these mean and wt actions it's perform Idea1
SQL stops working in every 15 days displaying message that database log file is full. Log file size is 3.95 GB. It is happening after shrinking the database also. What is solution to overcome this problem. Please help me as it's urgent.  4
how to find out the repeated value from table using groupby function?  3
What is a job?  3
What is user stored procedure & it purpose? Wipro3
What is transcation?Plz give One example?  2
How do we get month name in SQL Server 2000, Oracle, MS Access?  9
 
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