http://blog.bittersweetryan.com/2011/01/getting-generated-key-from-query-in.html.
On Jun 4, 2011 6:40 PM, "Jason Durham" <[email protected]> wrote: > It works on SQL 2008. > On Jun 4, 2011 6:35 PM, "Robert Rhodes" <[email protected]> wrote: >> >> That's for MYSQL. I am using SQL Server 2005. The docs say "identityCol" >> >> But I will give it a try...... >> >> Nope., didn't work. Thanks, though. :) >> >> On Sat, Jun 4, 2011 at 6:56 PM, Jason Durham <[email protected]> wrote: >> >>> >>> It's theResult.generatedKey >>> On Jun 4, 2011 4:46 PM, "Robert Rhodes" <[email protected]> wrote: >>> > >>> > I am frustrated. :( >>> > >>> > In the cf9 docs, it says that cfquery is supposed to return, in the >>> result >>> > variable, the identity column value of the inserted record. However it > is >>> > not working from me. >>> > >>> > Would one of you kind souls point out my mistake? >>> > >>> > <cfquery datasource="someDsn" name="insertRecord" result="theResult"> >>> > INSERT INTO >>> > someTable >>> > ( >>> > firstName, >>> > lastName >>> > ) >>> > VALUES >>> > ( >>> > <cfqueryparam cfsqltype="cf_sql_varchar" maxlength="20" >>> > value="#arguments.firstName#">, >>> > <cfqueryparam cfsqltype="cf_sql_varchar" maxlength="20" >>> > value="#arguments.lastName#"> >>> > ) >>> > </cfquery> >>> > >>> > <cfoutput>#theResult.identityCol#</cfoutput> >>> > >>> > When I run this, identityCol is not there. >>> > >>> > I am indeed using an autonumbering identity column in the database. >>> > >>> > Yes, I know I can just add a select to this query to get at it, but I >>> really >>> > want this to work, dammit! >>> > >>> > >>> > >>> >>> >> >> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:345078 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

