Suppresses the counting of the records. Normally a SQL statement stuck
within a CFQUERY tag can only return one record set. If I didn't set
NOCOUNT off then it would have returned 0 records because the insert
returned 0 records. However what I really want is the results from the
second query. The select statement. SET NOCOUNT allows me to get that.
It also allows you to do groups of many queries within one CFQUERY statement
as long as only one of them is a select statement.
Mark
-----Original Message-----
From: Metzy Martinez [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 24, 2001 4:50 PM
To: CF-Talk
Subject: RE: SQL INSERTS - return ID
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