Welcome. :) I seem to be giving that one out a lot lately -- or at least, noticing people still using @@identity a lot lately. :)
> Hmm. Hadn't heard that before. Thanks for the tip! > --Ben > S.Isaac Dealey wrote: >> i'm not sure if that's thread-safe tho... I don't >> remember offhand >> what set nocount does... but the @@identity variable is >> from any table >> in any sql server session across the database or possibly >> the server, >> not sure... SQL Server 2000 introduced a SCOPE_IDENTITY() >> function >> which _is_ thread-safe... >> >> <cfquery> >> insert stuff; >> select scope_identity() as something; >> </cfquery> >> >> This function ensures that the value returned is from the >> last table >> inserted in your currently executing batch -- so if it's >> not in your >> cfquery, it won't affect the result. (iirc including >> triggers on the >> table you're inserting into which has been known to cause >> problems >> with @@identity) ... so the rule of thumb is to use >> scope_identity() >> if you can. >> s. isaac dealey 954.927.5117 new epoch : isn't it time for a change? add features without fixtures with the onTap open source framework http://www.sys-con.com/story/?storyid=44477&DE=1 http://www.sys-con.com/story/?storyid=45569&DE=1 http://www.fusiontap.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Special thanks to the CF Community Suite Silver Sponsor - New Atlanta http://www.newatlanta.com Message: http://www.houseoffusion.com/lists.cfm/link=i:4:187121 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=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

