Quick Check


1. 

How can you tell SQL Server to roll back a transaction in case an error occurs?

image from book

2. 

What is the difference between the functions @@ERROR and ERROR_NUMBER()?

image from book

3. 

Can you commit a transaction in the catch block?

image from book

Answers

1. 

In the event of an error that might keep a transaction from completing successfully, you can tell SQL Server to roll back a transaction by setting the XACT_ABORT session option to ON.

2. 

The function @@ERROR returns the error number of the previously executed statement and can be used outside of a catch block. The function ERROR_NUMBER() returns the error number that belongs to the error that caused control to be transferred to the current catch block. If not inside of a catch block, ERROR_NUMBER() returns NULL.

3. 

Yes, you can commit a transaction in the catch block if the transaction is committable. Use the XACT_STATE() function to find out if it is.




MCITP Self-Paced Training Kit Exam 70-442  .Designing and Optimizing Data Access by Using Microsoft SQL Server 2005
MCITP Self-Paced Training Kit Exam 70-442 .Designing and Optimizing Data Access by Using Microsoft SQL Server 2005
ISBN: 073562383X
EAN: N/A
Year: 2007
Pages: 162

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net