Yes, I would agree that is a much simpler and safer alternative.  since
scope_identity() is already specific to your connection you don't have
to worry about locking and such altogether.

~Brad

-------- Original Message --------
Subject: Re: SQL Gurus... obtaining the correct Incremental ID
From: Leigh _ <[email protected]>
Date: Wed, April 28, 2010 4:44 pm
To: cf-talk <[email protected]>


>That would ONLY work if you used SET TRANSACTION ISOLATION LEVEL
>SERIALIZABLE or WITH(TABLOCKX HOLDLOCK)
>
>Even with with rowlock, another spid can insert additional records into
>the table and the select max() might return a bogus value.

Aside from being unsafe without the right isolation level, it is not
necessary in MSSQL 2005 or CF8+. As use mentioned use SCOPE_IDENTITY()
or cfquery's result attribute. 



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:333206
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to