Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2008
»
SQL Server Newbies
»
RETURN clause, clarification
RETURN clause, clarification
Rate Topic
Display Mode
Topic Options
Author
Message
autoexcrement
autoexcrement
Posted Friday, January 14, 2011 2:30 PM
Valued Member
Group: General Forum Members
Last Login: Thursday, May 09, 2013 5:23 PM
Points: 52,
Visits: 188
Sorry, this might be my dumbest post yet. But I can't seem to find a simple explanation.
I'm unclear on exactly what "RETURN" does. BoL says it "[immediately] exits unconditionally from a query or procedure."
But then in the context of a UDF, you have to have a RETURN clause, which is followed by stuff that you want to be returned.
So which is it? Does it exit immediately, or does it return stuff that follows it?
And then, to make matters worse for stupid people, there's also "RETURNS"...
"If I had been drinking out of that toilet, I might have been killed."
-Ace Ventura
Post #1048219
Jeff Moden
Jeff Moden
Posted Friday, January 14, 2011 2:45 PM
SSC-Dedicated
Group: General Forum Members
Last Login: Today @ 2:40 PM
Points: 32,896,
Visits: 26,778
autoexcrement (1/14/2011)
Sorry, this might be my dumbest post yet. But I can't seem to find a simple explanation.
I'm unclear on exactly what "RETURN" does. BoL says it "[immediately] exits unconditionally from a query or procedure."
But then in the context of a UDF, you have to have a RETURN clause, which is followed by stuff that you want to be returned.
So which is it? Does it exit immediately, or does it return stuff that follows it?
And then, to make matters worse for stupid people, there's also "RETURNS"...
RETURN does both. It exits the current proc and returns to the calling proc or the "system" that called it. If a value follows the RETURN, it also returns that value.
It is not usual to consider it to be an "abort" though because if a sproc is called from another sproc, the RETURN doesn't stop the outer sproc from continuing. It's more like a "RETURN" from GOSUB in BASIC.
--Jeff Moden
"
RBAR
is pronounced "ree-bar" and is a "Modenism" for "
R
ow-
B
y-
A
gonizing-
R
ow".
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Post #1048225
autoexcrement
autoexcrement
Posted Friday, January 14, 2011 2:48 PM
Valued Member
Group: General Forum Members
Last Login: Thursday, May 09, 2013 5:23 PM
Points: 52,
Visits: 188
THANK YOU!
"If I had been drinking out of that toilet, I might have been killed."
-Ace Ventura
Post #1048228
Jeff Moden
Jeff Moden
Posted Friday, January 14, 2011 4:51 PM
SSC-Dedicated
Group: General Forum Members
Last Login: Today @ 2:40 PM
Points: 32,896,
Visits: 26,778
You bet... thanks for the feedback.
--Jeff Moden
"
RBAR
is pronounced "ree-bar" and is a "Modenism" for "
R
ow-
B
y-
A
gonizing-
R
ow".
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Post #1048268
« Prev Topic
|
Next Topic »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.