Thursday, March 25, 2010

Transaction quiz

What will be the output of the following scripts (SQL Server 2005 or 2008)?
CREATE TABLE #Test(a TINYINT)
GO
BEGIN TRY
BEGIN TRAN OuterTran
BEGIN TRAN InnerTran
INSERT INTO #Test VALUES(1)
COMMIT TRAN InnerTran
INSERT INTO #Test VALUES(256) --Error occur here
COMMIT TRAN OuterTran
END TRY
BEGIN CATCH
ROLLBACK WORK
END CATCH
SELECT * FROM #Test

A. 1
B. Error occurs since there no ROLLBACK WORK command in T-SQL
C. Error occurs in the scripts
D. No record returns

Answer:[D]
Highlight to find out the answer.

No comments:

Post a Comment