I have a SQL Server stored procedure; I need to capture the return value from the stored procedure. Is this the correct way of doing this?
declare valback varchar(30)
set valback = exec storeproc1
In this case, storeproc1 is my stored procedure.
To start, use proper T-SQL syntax:
The only return type allowed for a stored procedure is
int. Stored procedures return status via thereturnstatement.I somehow have a feeling that you really want something else, namely:
to have an OUTPUT parameter in the procedure:
or capture the procedure result set via
INSERT ... EXEC. See How to Share Data Between Stored Procedures.