SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


ReturnValue vs. Output Parameter


ReturnValue vs. Output Parameter

Author
Message
meichner
meichner
Right there with Babe
Right there with Babe (753 reputation)Right there with Babe (753 reputation)Right there with Babe (753 reputation)Right there with Babe (753 reputation)Right there with Babe (753 reputation)Right there with Babe (753 reputation)Right there with Babe (753 reputation)Right there with Babe (753 reputation)

Group: General Forum Members
Points: 753 Visits: 640
I am a c# programmer. I need to be able to return the ID of a row that I just inserted into the database using SCOPE_IDENTITY(). I have seen implementations that return this value as an Output parameter and others as a ReturnValue. Is one method preferrable over the other? If so, why?

Thanks
JuncTheMayl
JuncTheMayl
Ten Centuries
Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)

Group: General Forum Members
Points: 1306 Visits: 490
i use return values to tell me whether or not a proc ran successfully or encountered any errors, and i use output parameters to return specific values encountered by the proc. you only have one return value, but potentially many output parameters.

that's just me though... i've seen others use return values to return specific values encountered by the proc.

edit: also, i believe return values can only return int values... parameters can return so much more.
meichner
meichner
Right there with Babe
Right there with Babe (753 reputation)Right there with Babe (753 reputation)Right there with Babe (753 reputation)Right there with Babe (753 reputation)Right there with Babe (753 reputation)Right there with Babe (753 reputation)Right there with Babe (753 reputation)Right there with Babe (753 reputation)

Group: General Forum Members
Points: 753 Visits: 640
Thanks. I got in a habit (good or bad) of raising errors when a problem occurs in a stored procedure as opposed to using return values. I am curious if there any down side to using Output parameters?

Thanks
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search