1. Home
  2. Computing & Technology
  3. Databases
photo of Mike Chapple
Mike's Databases Blog

By Mike Chapple, About.com Guide to Databases since 2000

Using TRY…CATCH to Handle SQL Server Errors

Tuesday June 24, 2008
The TRY…CATCH statement in Transact-SQL allows you to detect and handle error conditions gracefully within your database applications. This statement is the cornerstone of SQL Server error handling and is an extremely important part of developing robust database applications.

TRY..CATCH works by allowing you to specify two Transact-SQL statements: one that you wish to "try" and another that you wish to use to "catch" any errors that might arise. When SQL Server encounters a TRY..CATCH statement, it immediately executes the statement included in the TRY clause. If the TRY statement executes successfully, SQL Server simply moves on. On the other hand, if your TRY statement generates an error, SQL Server executes the CATCH statement to gracefully handle the error.

Read more: Using TRY…CATCH to Handle SQL Server Errors
Comments

No comments yet. Leave a Comment

Leave a Comment

Line and paragraph breaks are automatic. Some HTML allowed: <a href="" title="">, <b>, <i>, <strike>

Explore Databases
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Databases

©2009 About.com, a part of The New York Times Company.

All rights reserved.