O'Reilly logo

Microsoft® SQL Server™ 2000 Programming by Example by Carlos Eduardo Rojas, Fernando G. Guerrero

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Handling Errors

An important element of any program you write is the error-checking section. During software development, it is a good programming technique to check for errors in your code, and abort the execution of the program or trap the error when it is found. If the program crashes, there's a high probability that it crashed because you neglected to check or trap an error.

Transact-SQL provides twoelements that allow us to check and throw errors programmatically. These elements are the @@ERROR parameterless(or niladic) system function and the RAISERROR statement.

The @@ERROR system function returns the error code (an integer different from 0) of the last statement executed, if there was an error. On the other hand, if the last statement ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required