x

Issue with return status in SP

  begin try 
 
 select 1/0 as 'an error' 
 
 end try 
 
 begin catch 
 
 select ERROR_NUMBER() as 'ERROR_NUMBER',  
        ERROR_SEVERITY() as 'ERROR_SEVERITY', 
        ERROR_STATE() as 'ERROR_STATE', 
        LEFT(ERROR_PROCEDURE(),50) as 'ERROR_PROCEDURE', 
        ERROR_LINE() as 'ERROR_LINE' ,  
        LEFT(ERROR_MESSAGE(),40) as 'ERROR_MESSAGE'     
 end catch 
 

want to know what it returns... when we execute a SP, it always have a return status... as in 0 for success.. returns -ve values for error...I am trying to find out what diff error codes are...

more ▼

asked Oct 20, 2011 at 09:40 AM in Default

avatar image

user123
11 2 3 3

(comments are locked)
10|1200 characters needed characters left

1 answer: sort voted first

Error codes? Try SELECT * FROM sys.messages as documented here: http://msdn.microsoft.com/en-us/library/ms187382.aspx

more ▼

answered Oct 20, 2011 at 10:13 AM

avatar image

ThomasRushton ♦♦
42.4k 20 60 54

Limiting those to where language_id = 1033 kinda helps to filter out the error messages text for other than English languages.

Oct 20, 2011 at 10:17 AM Oleg
(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x449

asked: Oct 20, 2011 at 09:40 AM

Seen: 861 times

Last Updated: Jan 04, 2012 at 12:36 PM

Copyright 2018 Redgate Software. Privacy Policy