Usually I just put in an insert trigger like "select id from inserted",
since it works for insert...select as well. Is there any downside to doing
that?
----- Original Message -----
From: "Dave Watts" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Wednesday, March 21, 2001 9:02 AM
Subject: RE: @@identity
> > I am curious, I replaced the
> > SELECT newID = @@identity
> > with
> > SELECT max(id) as myVar
> >
> > and max(id) is faster than your example in my application. Is
> > there a reason that @@identity is "better" than max(id), other
> > than the stated SQL Server issues?
>
> Using @@IDENTITY in this case makes it less likely that you'll have a
> concurrency issue. If you simply insert the new record, then query for the
> highest identity value, it's possible that someone else will have inserted
a
> record between your insert and your SELECT MAX query. If that happens,
then
> you'll get the wrong identity value. Using @@IDENTITY ensures that you get
> the identity value from your insert.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists