March 29, 2007 at 10:49 am
Good afternoon. I'm trying to return the SCOPE_IDENTITY value in this stored procedure:
ALTER proc [dbo].[insertnewabsencerequest]
@requesttype tinyint
, @empnum smallint
, @startdate smalldatetime
, @enddate smalldatetime
, @comments varchar(250)
, @newid int output
as
insert timemgmt.dbo.tblabsencerequest(requesttype, empnum, startdate, enddate, comments)
values(@requesttype, @empnum, @startdate, @enddate, @comments)
select @newid = scope_identity()
When I try to execute the stored procedure I get the following error:
Server: Msg 201, Level 16, State 4, Procedure insertnewabsencerequest, Line 0
Procedure 'insertnewabsencerequest' expects parameter '@newid', which was not supplied.
I know I'm missing something simple. Can anyone assist me? Thanks.
March 29, 2007 at 11:00 am
I'm guessing that you're not passing the output parameter. Your best bet is to look at the BOL examples under CREATE PROCEDURE, as they show you examples of how to actually use the value you're getting back.
March 29, 2007 at 11:09 am
Declare @out as int
exec dbo.MyProc @out output
PRINT @out
You must supply the parameter in that fashion to execute the procedure.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply