sexta-feira, dezembro 30, 2005

SQLSERVER 2005 - Transact-SQL Error Handling

Article from Carvin Wilson:
http://www.15seconds.com/issue/010312.htm
(In English)
Summary:

"OVERVIEW

The robust Transact-SQL (T-SQL) syntax in SQL Server provides developers with an efficient way to handle errors within stored procedures. This article discusses the @@ERROR, SP_ADDMESSAGE, and RAISERROR functions within SQL Server.

The @@ERROR Function

Upon the completion of any T-SQL statement, SQL Server sets the @@ERROR object. If the statement was successful, @@ERROR is set to 0, otherwise it is set to the designate error code. All SQL Server error codes can be found within the master.dbo.sysmessages system table. One important thing to remember is that @@ERROR is cleared each time a statement is executed. It is a good practice to store the value within a local variable.
"

Sem comentários: