Hey folks, On MSSQL, using @@IDENTITY is a bad idea. Use SCOPE_IDENTITY() instead. Google "@@IDENTITY" and you'll get plenty of details as to why.
-Joe On 6/2/06, Nick Tong - TalkWebSolutions.co.uk <[EMAIL PROTECTED]> wrote: > Ken, > > <cfquery datasource="yourdsn" name="myInsert"> > INSERT INTO myable (columns) > VALUES(values) > SELECT @@IDENTITY AS lastID > </cfquery> > > <cfoutput>#myinsert.lastID#</cfoutput> > > On 02/06/06, Ken <[EMAIL PROTECTED]> wrote: > > Hi. I am doing a Insert statement into my db, and immediately after > > the Insert I need to fetch the value of the field ID (Identity). > > I know I could do a Select Max(ID), but how else can I fetch the value > > of the last inserted record? DB: SQL 2000. > > Please help. > > > > - Ken. > > > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:242194 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

