April 7, 2005 at 2:36 pm
Whats best, for reporting developers created return numbers.Why ?
RETURN -100
RETURN 100
April 8, 2005 at 7:51 am
I'm guessing you trying to determine when you pass back an error?
Most of it is personal preference. I prefer to send back a 0 if all is good and the actual @@ERROR number if there was an error of some sort. However, depending on my need, I've sent back the error number in the OUTPUT parameters. I would say as long as you create consistency, you should be fine with either style. Negative numbers (if creating more of a 'custom' error will eliminate any confusion from the @@ERROR values I described above).
April 8, 2005 at 12:50 pm
The default return from a stored procedure is 0. So I have all my stored procedures explicitly return 1 to indicate success. Anything else I consider to be an error and terminate/rollback processing.
There are many other good ways to handle return codes. Here is a good article on error handling: http://www.sommarskog.se/error-handling-II.html#presumptions
April 9, 2005 at 1:00 pm
After more readings I found that SQL server returns positive error numbers, so if I use negative numbers, then I can confirm that the error number is of my creation as a developer.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply