May 2006
Intermediate to advanced
536 pages
15h 13m
English
Now that I’ve covered exception handling and exception-handling limitations in SQL Server 2000, I’ll discuss exception handling in SQL Server 2005.
SQL Server 2005 introduces the new TRY/CATCH construct. To use it, you place the suspect code in a BEGIN TRY/END TRY block, followed by a BEGIN CATCH/END CATCH block. When an error is encountered in the TRY block, the error is "trapped," and control is passed to the nearest CATCH block, where you have your exception-handling code. If you trap an error, no error message will be generated and sent to the caller. If you want to throw an error to the caller, you can do so using the RAISERROR command. If no error was generated in the TRY block, the CATCH block ...
Read now
Unlock full access