I have a stored procedure that inserts into a table then executes this line
SET @returnVal = SCOPE_IDENTITY();
and after that I\'ve tried both:
Declare a output type of parameter in your procedure definition:
create procedure [dbo].[Procedurename] @returnVal int output as SET @returnVal = SCOPE_IDENTITY();
and while calling the stored procedure call it as:
declare @returnVal int exec Procedurename @returnVal output print @returnVal