>> Handling sql errors

J

Jonathan

Hi, using Access 2003 and SQL 2005.
I currently have stored procedures that do record updates. I would like to
return custom error numbers.

The following example returns 50000 as the error number as this syntax is
used for messages. How can I adjust the raiserror to return the error number?

*** Code Example***
BEGIN TRY
....
RAISERROR ('50005',11,1)
....
END TRY

BEGIN CATCH
SELECT @@ERROR
END CATCH
***

Any ideas or suggestions appreciated :)

Many thanks,
Jonathan
 
S

Stefan Hoffmann

hi Jonathan,
Hi, using Access 2003 and SQL 2005.
I currently have stored procedures that do record updates. I would like to
return custom error numbers.

The following example returns 50000 as the error number as this syntax is
used for messages. How can I adjust the raiserror to return the error number?

RAISERROR ('50005',11,1)
The @@ERROR always returns 50000, if you specify a message:

http://msdn.microsoft.com/en-us/library/ms178592.aspx

Use @@ERROR_MESSAGE instead:

http://msdn.microsoft.com/en-us/library/ms179296.aspx


mfG
--> stefan <--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top