This is a discussion on Return versus Raiserror within the SQL Server forums, part of the Microsoft SQL Server category; --> I am trying to get a better understanding of when to use return (with a print statement) and when ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| I am trying to get a better understanding of when to use return (with a print statement) and when to use raiserror. * Both statements can be used with stored procedures while only return can be used with functions. * With raiserror it is easy to have multiple errors thrown. (If both the calling procedure and called procedure both try to handle error) Wow. Thought I could think of more. So that really leaves me with very little info on the proper use of these two statements. |
| |||
| Jason (JayCallas@hotmail.com) writes: > I am trying to get a better understanding of when to use return (with > a print statement) and when to use raiserror. > > * Both statements can be used with stored procedures while only return > can be used with functions. > > * With raiserror it is easy to have multiple errors thrown. (If both > the calling procedure and called procedure both try to handle error) > > Wow. Thought I could think of more. So that really leaves me with very > little info on the proper use of these two statements. I'd say use both. Raiserror informs the client that things went bad. RETURN informs the calling stored procedure that things went bad. If you want to read more about error handling, I have an article on my web site that may be of interest: http://www.algonet.se/~sommar/error-handling-II.html. -- Erland Sommarskog, SQL Server MVP, sommar@algonet.se Books Online for SQL Server SP3 at http://www.microsoft.com/sql/techinf...2000/books.asp |
| ||||
| I like LOG and NOWAIT options of RAISERROR. "Jason" <JayCallas@hotmail.com> wrote in message news:f01a7c89.0312081233.2e8802d0@posting.google.c om... > I am trying to get a better understanding of when to use return (with > a print statement) and when to use raiserror. > > * Both statements can be used with stored procedures while only return > can be used with functions. > > * With raiserror it is easy to have multiple errors thrown. (If both > the calling procedure and called procedure both try to handle error) > > Wow. Thought I could think of more. So that really leaves me with very > little info on the proper use of these two statements. |