I have not come across @@identity so I use the following code (some stuff
deleted)

<CFLOCK TIMEOUT="15"
        THROWONTIMEOUT="No"
        NAME="NewWebItem"
        TYPE="EXCLUSIVE">
<CFQUERY NAME="webadd" DATASOURCE="WebItems">

INSERT INTO WebItems(   snip...

                                                )
</CFQUERY>

<CFQUERY NAME="WhatID" DATASOURCE="webitems">
        SELECT     max( WebItemID) as WEBITEMlastID
        FROM         WebItems 
</CFQUERY>

</CFLOCK>

<CFOUTPUT QUERY="WhatID">
        <CFSET WebItemID = #WEBITEMlastID#>
</CFOUTPUT>



-----Original Message-----
From: Dylan Bromby [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, 20 March 2001 16:38
To: CF-Talk
Subject: RE: @@identity


make it a stored procedure. use the OUTPUT feature of T-SQL to get at the
identity.

-----Original Message-----
From: Joshua Tipton [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 19, 2001 8:32 PM
To: CF-Talk
Subject: @@identity


I know how to use @@identity to select the last inserted record right under
an insert but how do I display that id of that record?

<cfquery name="" datasource="gunledger" dbtype="ODBC">
INSERT INTO dbo.distrib(compname, phonenum, address, address2, city, state,
zip, fflid, expires)
VALUES('#compname#', '#phonenum#', '#address#', '#address2#', '#city#',
'#state#', '#zip#', '#fflid#', '#expires#')
select @@identity as 'identity'
</cfquery>

How do I output the identity????

Josh
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to