How To Catch Errors While Inserting Values in Table [SQL Server]

If you often get errors when in inserting values in the table, use the TRY..CATCH. If you are using SQL Server 2005 or greater, you can take advantage of this set of tools for handling errors. By taking advantage of this features, you can focus more on IT business strategy development and less on the errors.

Here’s an example taken from sqlauthority.com:

First create a simple table, then insert values in this table which we will throw errors and the same errors will catch on the table.

Using the TRY.. CATCH the error will be displayed in the SELECT statement.

Read the rest of the tutorial here: http://blog.sqlauthority.com/2014/10/05/sql-server-how-to-catch-errors-while-inserting-values-in-table/

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS
Email
Print