Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 SQL

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-01-30 : 08:53:19
Palvinder Singh writes "How do I trap or clear an Error in the stored Procedure."

JustinBigelow
SQL Gigolo

1157 Posts

Posted - 2002-01-30 : 09:03:48
Use the @@error system variable.

Taken from Books On Line...

When Microsoft® SQL Server™ completes the execution of a Transact-SQL statement, @@ERROR is set to the value 0 if the statement executed successfully. If an error occurs, an error message is returned. @@ERROR returns the number of the error message until another Transact-SQL statement is executed. You can view the text associated with an @@ERROR error number in the sysmessages system table.

Because @@ERROR is cleared and reset on each statement executed, check it immediately following the statement being validated or save it to a local variable that can be checked later.


hth,
Justin


Go to Top of Page
   

- Advertisement -