SET NOCOUNT - determines if SQL returns the number of rows affected by the SQL 
command. So for an insert ... SQL would return a 1 (if successfully insert one row) or 
0 (if the insert failed due to unique constraint or something) for the number of rows 
affected vice the SELECT @@identity. CFQUERY expects a single return set and drops the 
others ... first one back wins.

Note that if the INSERT was wrapped in a stored procedure and you used cfstoredproc, 
you could return multiple result sets and in one have the number of rows affected and 
the @@identity value in another etc.
Bill

In a message dated Tue, 15 May 2001  1:21:17 PM Eastern Daylight Time, "Mike Kear" 
<[EMAIL PROTECTED]> writes:

<< What does the "set nocount on" do?

Cheers,
Mike Kear
Windsor, NSW, Australia
AFP WebWorks


-----Original Message-----
From: Diana Nichols [mailto:[EMAIL PROTECTED]]
 
set nocount on
insert into table ()
values ()
select @@identity as newID
set nocount off

HTH
D
*************
Diana Nichols
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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