I had the same problem a few days ago and that is the way i solved with
SELECT @@IDENTITY

then you are able to retrieve the id and even feed it to another stored proc
by specifying the name of stored proc
ex.
#getreal.id#

what does SET NOCOUNT OFF due?

Metzy



-----Original Message-----
From: mjohnson [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 24, 2001 10:23 AM
To: CF-Talk
Subject: RE: SQL INSERTS - return ID


Using SQL Server you can either do it with a stored procedure or do
something like this.

<CFQUERY ...
SET NOCOUNT ON

INSERT INTO somtable
(columns)
VALUES
(values)

SELECT @@IDENTITY  -- grab the id of the last inserted record into an
identity column

SET NOCOUNT OFF
</CFQUERY>

Mark

-----Original Message-----
From: Matt Eschenbaum [mailto:[EMAIL PROTECTED]]
Sent: Monday, April 23, 2001 4:36 PM
To: CF-Talk
Subject: SQL INSERTS - return ID


Anyone know a trick to return the ID of a record just Inserted into a table?

Sincerely,

Matthew M. Eschenbaum
Allaire Certified Professional
DevTech Inc.
[EMAIL PROTECTED]
206.956.0888
www.dev-tech.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to