Very cool. I added that as a snippet. I will be using this again for sure. Much olbiged :) Candace K. Cottrell, Web Developer The Children's Medical Center One Children's Plaza Dayton, OH 45404 937-641-4293 http://www.childrensdayton.org [EMAIL PROTECTED]
>>> [EMAIL PROTECTED] 3/21/2003 8:35:10 AM >>> Try <CFQUERY NAME="qryFoo" DATASOURCE="bar"> SET NOCOUNT ON INSERT INTO () VALUES () SELECT id = Scope_Identity() SET NOCOUNT OFF </CFQUERY> <CFOUTPUT>#qryFoo.ID#</CFOUTPUT> HTH -----Original Message----- From: Candace Cottrell [mailto:[EMAIL PROTECTED] Sent: Friday, March 21, 2003 13:31 To: CF-Community Subject: RE: Referencing my last record Thanks Tim... I am using SQL Server. Now how do I reference MyID outside the cfquery? This isn't working.. <cfquery name="InsertType" datasource="resDB"> Insert Into TYPE ( TypeName, TypeDesc ) Values ( '#form.TypeName#', '#form.TypeDesc#' ) select @@identity as myID from type </cfquery> <cfset lastID = InsertType.myID> <cfquery name="getLast" datasource="resDB"> SELECT TYPE.typeID, TYPE.typeName, TYPE.typeDesc FROM TYPE Where TypeID = #lastID# </cfquery> It's saying Element MYID is undefined in INSERTTYPE. Thanks for all your help :) Candace K. Cottrell, Web Developer The Children's Medical Center One Children's Plaza Dayton, OH 45404 937-641-4293 http://www.childrensdayton.org [EMAIL PROTECTED] >>> [EMAIL PROTECTED] 3/20/2003 3:28:13 PM >>> Is it SQL Server? use @@identity to get the max id in SQL Server so something like: <cfquery name="InsertType" datasource="resDB"> Insert Into TYPE ( TypeName, TypeDesc ) Values ( '#form.TypeName#', '#form.TypeDesc#' ) select @@identity as myID from type </cfquery> -----Original Message----- From: Candace Cottrell [mailto:[EMAIL PROTECTED] Sent: Thursday, March 20, 2003 3:01 PM To: CF-Community Subject: Referencing my last record Is there any way to reference the ID of the last record I added? <cfquery name="InsertType" datasource="resDB"> Insert Into TYPE (TypeName, TypeDesc) Values ('#form.TypeName#', '#form.TypeDesc#') </cfquery> Something like: <cfset lastID = InsertType.TypeID> TypeID is an identity field in MSSQL. Candace K. Cottrell, Web Developer The Children's Medical Center One Children's Plaza Dayton, OH 45404 937-641-4293 http://www.childrensdayton.org [EMAIL PROTECTED] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=5 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=5 Get the mailserver that powers this list at http://www.coolfusion.com Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.5
