Unix Technical Forum

Return versus Raiserror

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 ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 08:07 PM
Jason
 
Posts: n/a
Default Return versus Raiserror

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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 08:08 PM
Erland Sommarskog
 
Posts: n/a
Default Re: Return versus Raiserror

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-28-2008, 08:08 PM
Igor Raytsin
 
Posts: n/a
Default Re: Return versus Raiserror

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.



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:11 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com