> 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.
Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
voice: (202) 797-5496
fax: (202) 797-5444
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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