Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

ReturnValue vs. Output Parameter Expand / Collapse
Author
Message
Posted Tuesday, August 12, 2008 6:54 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Monday, February 6, 2012 12:43 PM
Points: 215, 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
Post #550931
Posted Tuesday, August 12, 2008 7:08 AM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Tuesday, November 11, 2014 1:18 PM
Points: 944, Visits: 451
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.
Post #550948
Posted Tuesday, August 12, 2008 7:56 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Monday, February 6, 2012 12:43 PM
Points: 215, 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
Post #551014
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse