Or in the stored procedure you could save the @@IDENTITY in a variable and
return it at the end...  i.e:

/*Do an insert here*/
INSERT BLAH BLAH

DECLARE StoredId INT

SELECT StoredId = @@IDENTITY

/*Do 2nd Insert Statement*/
INSERT BLAH BLAH 

SELECT @StoreId

This still doesn't require the need for any additional triggers to be
written and maintained.



> From: [EMAIL PROTECTED] (Paul Hastings)
> Organization: TEI
> Reply-To: [EMAIL PROTECTED]
> Date: Mon, 3 Jul 2000 13:40:09 +0700
> To: <[EMAIL PROTECTED]>
> Subject: Re: return value of Identity Column
> 
>>> wrong.  It's the last identity value used by that connection.
>> 
>> i was previously told on this list that @@IDENTITY is per connection per
>> table.
> 
> no, its per connection. if you insert a table that has a trigger that fires
> an insert into another table w/identity, then @@IDENTITY will contain
> the 2nd table's value. in these cases its easy enough to re-write the
> triggers to grab the 1st @@IDENTITY & hold it in a local var
> to send back to the caller.
> 
> ------------------------------------------------------------------------------
> Archives: http://www.eGroups.com/list/cf-talk
> To Unsubscribe visit
> http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or
> send a message to [EMAIL PROTECTED] with 'unsubscribe' in the
> body.

------------------------------------------------------------------------------
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to