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)
 Error Description

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-04-16 : 10:06:13
Shivani writes "How can I retrieve the error description from the clause @@Error in a stored procedure?"

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2002-04-16 : 11:07:10
@@ERROR is not a clause, it is a system function. Clauses are things like 'FROM', 'GROUP BY', 'SELECT'... @@ERROR returns the error number for the last Transact-SQL statement executed. There is not 'description'. However, "you can view the text associated with an @@ERROR error number in the sysmessages system table."

quote:

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.
-BOL



<O>
Go to Top of Page

VyasKN
SQL Server MVP &amp; SQLTeam MVY

313 Posts

Posted - 2002-04-16 : 11:18:50
Shivani, please read the following FAQ entries from my site:

http://vyaskn.tripod.com/programming_faq.htm#q7
http://vyaskn.tripod.com/programming_faq.htm#q11

--
HTH,
Vyas
Check out my SQL Server site @
http://vyaskn.tripod.com
Go to Top of Page

Shivani
Starting Member

4 Posts

Posted - 2002-04-17 : 03:17:48
quote:

@@ERROR is not a clause, it is a system function. Clauses are things like 'FROM', 'GROUP BY', 'SELECT'... @@ERROR returns the error number for the last Transact-SQL statement executed. There is not 'description'. However, "you can view the text associated with an @@ERROR error number in the sysmessages system table."

quote:

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.
-BOL



<O>



Go to Top of Page
   

- Advertisement -