• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 637
  • Last Modified:

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
0
aswam1975
Asked:
aswam1975
1 Solution
 
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

Featured Post

Microsoft Certification Exam 74-409

VeeamĀ® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now