Date parsed: 20/10/2007 13:36:02
Date: Sat, 20 Oct 2007 20:36:02 -0700
It's not really a question of having more than one table with identity. If
you had a single table with an identity and you inserted a row and had a
trigger that inserted another row (unlikely not not impossible) then
@@Identity will return the 2nd inserts value not the original insert. There
is really no reason to use @@Identity anymore now that we have the others.
--
Andrew J. Kelly SQL MVP
Solid Quality Mentors
"Jay" <spam@nospam.org> wrote in message
news:eEz09Z4EIHA.5228@TK2MSFTNGP05.phx.gbl...
> Excellent point, thank you.
>
> I've only had a minor need to use an IDENTITY anyway, so it's only been a
> single table that's had an IDENTITY when I've dealt with it.
>
> @@IDENTITY, SCOPE_IDENTITY & IDENT_CURRENT('table') do indeed make sense
> and BOL is very clear.
>
> Thanks,
> Jay
>
> "Robert Klemme" <shortcutter@googlemail.com> wrote in message
> news:5nuhbpFjqlttU1@mid.individual.net...
>> On 20.10.2007 15:26, Jay wrote:
>>> Nope, it is designed to give you the correct value. You can also use the
>>> system variable @@IDENTITY.
>>>
>>> Both 100% guaranteed to work correctly.
>>
>> Well, both are guaranteed to work correctly (i.e. as specified). But
>> there is a difference between the two which makes scope_identity the
>> better choice. This is all written down in the documentation, e.g.
>>
>>
http://msdn2.microsoft.com/en-us/library/ms190315.aspx>>
>> Regards
>>
>> robert
>>
>>
>> PS: Please do not top post.
>
>