From: DavidC on
I have a stored procedure that does 3 INSERTs and I want to use the new
identity value in each one to pass to the next INSERT. Can I use
SCOPE_IDENTITY() on each one without a problem? For example:

INSERT INTO ....

SET @newIdent = SCOPE_IDENTITY()

INSERT INTO .....

SET @newIdent2 = SCOPE_IDENTITY

--
David
From: Tom on
On Jun 21, 2:33 pm, DavidC <dlch...(a)lifetimeinc.com> wrote:
> I have a stored procedure that does 3 INSERTs and I want to use the new
> identity value in each one to pass to the next INSERT. Can I use
> SCOPE_IDENTITY() on each one without a problem?  For example:
>
> INSERT INTO ....
>
> SET @newIdent = SCOPE_IDENTITY()
>
> INSERT INTO .....
>
> SET @newIdent2 = SCOPE_IDENTITY
>
> --
> David

Yes that is not a problem.