Thanks everyone, works perfectly. -----Original Message----- From: Robertson-Ravo, Neil (RX) [mailto:[EMAIL PROTECTED] Sent: Thursday, 18 January 2007 6:30 PM To: CF-Talk Subject: SPAM-LOW: Re: Getting auto generated id after insert in MSSQL
Indeed, this is clearly identified within BOL. In most cases, where you know the schema etc then @@identity will work but to be safe it is best to use one of the scoped returns. -----Original Message----- From: Doug Bezona To: CF-Talk Sent: Thu Jan 18 03:27:48 2007 Subject: RE: Getting auto generated id after insert in MSSQL scope_identity() is preferrable to @@identity. @@identity will return the latest ID generated by your statement, which means if your insert kicks off a trigger, for example, and the trigger also uses an ID value, you would get the ID from the trigger, not your main insert. Scope_identity() is restricted to the scope of your main query. Now, chances are you don't have any triggers in play, but it's better to get in the habit of using scope_identity() so you don't have a surprise down the road. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Upgrade to Adobe ColdFusion MX7 Experience Flex 2 & MX7 integration & create powerful cross-platform RIAs http:http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:266851 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

