[dba-SQLServer] Stored Proc RETURN

Asger Blond ab-mi at post3.tele.dk
Wed Dec 9 10:08:08 CST 2009


Typo, the execution should be like this:

DECLARE @retval int
EXEC @retval = MySP
SELECT @retval

Asger


-----Oprindelig meddelelse-----
Fra: dba-sqlserver-bounces at databaseadvisors.com
[mailto:dba-sqlserver-bounces at databaseadvisors.com] På vegne af Asger Blond
Sendt: 9. december 2009 16:53
Til: 'Discussion concerning MS SQL Server'
Emne: Re: [dba-SQLServer] Stored Proc RETURN

It causes an immediate exit from the SP. It might also return an integer
value if you state for instance RETURN 2.
To get the integer value from the RETURN however you have to execute the SP
like this:
DECLARE @retval int
@retval = EXEC MySP
SELECT @retval
Asger

-----Oprindelig meddelelse-----
Fra: dba-sqlserver-bounces at databaseadvisors.com
[mailto:dba-sqlserver-bounces at databaseadvisors.com] På vegne af jwcolby
Sendt: 8. december 2009 23:26
Til: Dba-Sqlserver
Emne: [dba-SQLServer] Stored Proc RETURN

Does the RETURN statement cause an immediate exit from the SP, returning a
value in the process?  Or 
does it simply set the return variable?

-- 
John W. Colby
www.ColbyConsulting.com
_______________________________________________
dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
http://www.databaseadvisors.com


_______________________________________________
dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
http://www.databaseadvisors.com





More information about the dba-SQLServer mailing list