Error Reporting in Stored Procedures

I have a master stored procedure,sp_overall_proc.This executes 2 stored procs,sp_proc1 and sp_proc2.

All that these sp_proc1 and sp_proc2 do is populate tables,based on certain conditions.
Inside of each,I have checked for errors and assigned to local variables and done simple print messages.Is there a way I can pass these error codes to the overall stored procedure ,such that error reporting is done by the sp_overall_proc rather than the internal stored procedures?

Thanks
aswam1975Asked:
Who is Participating?
 
sigmaconCommented:
Yes, you can return numeric code from a stored procedure. Assume you have a local variable @errCode in your stored proc, then you can return from that stored procedure with

return (@errCode)

Make sure you have the parentheses around the variable. You would call this from the main stored procedure like this:

execute @returnedError = sp_proc2 ...
0
 
aswam1975Author Commented:
thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.