I know that there is another question with nearly the same title, but it doesn\'t answer my question. I have a stored procedure, which returns the unique identifier after in
Do you get the value of you EXEC
in TSQL? I wonder if refactoring the TSQL would help (and using SCOPE_IDENTITY()
:
so change:
COMMIT TRAN T1
RETURN @@IDENTITY
to:
SET @auctionID = SCOPE_IDENTITY()
COMMIT TRAN T1
RETURN @auctionID
(I would also change the other @@IDENTITY
to SCOPE_IDENTITY()
)
As a minor optimisation, you could also use:
return (int)retval.Value;
but this side of things should have worked "as is" from what I can see (hence why I'm focusing on the TSQL).