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
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.5
                                

Reply via email to