July 7, 2005 at 9:04 am
Hi,
Trying to return a value from one stored proc to another.
the first looks something like this
CREATE PROCEDURE usp_AddTest @name char(10), @id int output
AS
Insert into tbTest Values(@name)
Set @id = @@IDENTITY
Then from another proc i want to to do something like
declare @id
select @id = exec usp_addtest 'bob'
to return the @@identity
is this possible? many thanks.
Growing old is mandatory, growing up is optional
July 7, 2005 at 9:06 am
declare @id
exec usp_addtest 'bob', @id output
July 7, 2005 at 9:07 am
Your almost there.
If your using sql_Server 2000 then use scope_identity() instead of @@identity. Look up scope_identity in books online if you want a brief explaination why.
declare @id
-- This will get you there
exec usp_addtest 'bob', @id OUTPUT
select @id
July 7, 2005 at 9:14 am
wow, that was quick guys!
I was almost there, so close!
Unfortunately we're still running v7.
Thanks
Growing old is mandatory, growing up is optional
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply