Yes, using @@Identity will send you back the LAST inserted ID in that
query/stored proc...

Which means, if you do 2 inserts in a stored proc and you do a Select
@@Identity as RetId, RetId will be from the last insert.

I just did this on SQL Server 7 and it produced this result... I can
try on SQL 2000 later if I need to...

On 4/18/05, Kerry <[EMAIL PROTECTED]> wrote:
> >@@IDENTITY gives you the  identity from the last insert in the
> > database
> 
> hmmm, BOL says:
> "@@IDENTITY contains the last value generated in any table in the current
> session"
> 
> Anyone know what SQL defines as a session? i.e. is it just that query?
> If so, then @@IDENTITY is 100% safe where I am doing single inserts per
> query (no triggers in DB)...
> 
> -----Original Message-----
> From: Paul Hastings [mailto:[EMAIL PROTECTED]
> Sent: 18 April 2005 15:00
> To: CF-Talk
> Subject: Re: Last ID inserted
> 
> Mike Kear wrote:
> > Michael got the extract right.   True, books on line doesnt say NOT to
> > use @@identity, but it does say it's risky if there are several
> > inserts going on at once.
> 
> again, where exactly does it say that?
> 
> >
> > @@IDENTITY gives you the  identity from the last insert in the
> > database, whereever it was.  Which might or might not be the one you
> 
> that is an urban myth or a lack of understanding of how IDENTITY works,
> take your pick. but repeatedly saying that sort of thing based on the
> BoL as reference when it obviously isn't, doesn't make any sense to me.
> 
> 
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:203226
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to