How to get the error number?

Last Post 03 Aug 2006 09:53 PM by jmnobre. 2 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
shrikantpy
New Member
New Member

--
31 Jul 2006 10:33 PM
I had got the error message using @@spid function.
But I want to get the error number when there are more errors occured.
Can anyone help me to get the same.

Thank you.
jmnobre
New Member
New Member

--
03 Aug 2006 09:53 PM
Can't understand you... @@SPID returns the current process identifier not the current error... Assuming you mean the @@ERROR variable, this only returns the *last* error!
In theory you should test all your statements for an error, e.g.:

SELECT * FROM ...

IF @@ERROR <> 0 BEGIN ... process this error here ... END

UPDATE ....

IF @@ERROR <> 0 BEGIN ... process this error here ... END

etc...

If you want to collect all your errors to report them in one go at the end... you have to do it on a statement basis, that is for example, use a temporary table to store each error (on the 'process this error here' in the sample above) and at the end, just report them!

Hope it helps
jmn

SQLUSA
New Member
New Member

--
20 Aug 2006 02:30 AM
To help you, you have to provide us with the script.

@@spid is not a function.

It is a system variable.

Kalman Toth, Database, Data Warehouse and BI Architect
http://www.sqlusa.com/order2005/
The Best SQL Server 2005 Training in the World
You are not authorized to post a reply.

Acceptable Use Policy