When SET NOCOUNT is ON, the count (indicating the number of rows affected by a 
Transact-SQL statement) is not returned. When SET NOCOUNT is OFF, the count is 
returned.

The @@ROWCOUNT function is updated even when SET NOCOUNT is ON.

SET NOCOUNT ON eliminates the sending of DONE_IN_PROC messages to the client for each 
statement in a stored procedure. When using the utilities provided with Microsoft� SQL 
Server* to execute queries, the results prevent "nn rows affected" from being 
displayed at the end Transact-SQL statements such as SELECT, INSERT, UPDATE, and 
DELETE.

For stored procedures that contain several statements that do not return much actual 
data, this can provide a significant performance boost because network traffic is 
greatly reduced.

The setting of SET NOCOUNT is set at execute or run time and not at parse time.

FYI,
The Fuesebox list has moved to topica.

Linda Leslie
Global Cloud
Database and Application Developer

>>> [EMAIL PROTECTED] 08/23/01 11:31AM >>>
What does the NOCOUNT do?  Don't you just need @@IDENTITY?

Shawn

-----Original Message-----
From: Ross [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, August 23, 2001 9:04 AM
To: Fusebox
Subject: Re: OFF: Unique row id in SQL select statement


You didn't say what db server you are running but if you are running MS
SQL Server and don't mind sacrificing portability then this type of
thing works very well:

<cfquery name="MyQuery">
SET NOCOUNT ON
INSERT INTO MyTable
(Field1, Field2)
VALUES(#myField1#, #myField2#)>
SET NOCOUNT OFF
SELECT @@IDENTITY AS ID
</cfquery>

The new ID is then available as MyQuery.ID


--- Yuri Vorontsov <[EMAIL PROTECTED]> wrote:
> One more off-topic question. Does anyone know how one can retrieve
> a unique id of a row in a SQL query? I need smth like:
> 
> select ???? as this_row_uid
> 
> Any ideas?
> Thanks a lot!
> 
> Yuri 
> 
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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