October 5, 2007 at 7:16 am
I am looking for some clarity on the proper use of a Return Statement. As I understand things a Return statement in a Stored procedure is used to return a value to a calling procedure or application. Often used to identify specific type of errors and allow the calling application the ability to execute some logic based on this return value.
A return value does not cause a SQL server Job execution to fail i.e. the return of a non-zero value like 1, 2 etc. does not automatically cause a SQL Server scheduled Job to fail. These values simply allow a calling procedure some idea why the procedure failed depending on the logic in the procedure.
Appreciate validation, correction or clarification of the above statements.
Thanks,
October 5, 2007 at 9:17 am
Mark, I think you've described this well.
I tend to add a "return" to all my procs, which returns 0 by default. It's just an easy way for me to see where they end. I have used this to return values as in
exec @x = myfavoriteproc
It's easier than output parameters to me, or maybe it's an old habit from programming days.
October 9, 2007 at 7:50 am
Thanks Steve:)
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply