|
Re:Row count in sqlserver
Returns the number of rows affected by the last statement.
Syntax
@@ROWCOUNT
Return Types
integer
Remarks
This variable is set to 0 by any statement that does not return rows, such as an IF statement.
this is how it works...
UPDATE authors SET au_lname = \'Jones\'
WHERE au_id = \'999-888-7777\'
IF @@ROWCOUNT = 0
print \'Warning: No rows were updated\'
here is another way of using it ..
You can use the SET ROWCOUNT statement or the TOP clause of the select statement (there is no TOP clause in SQL Server 6.5).
There are examples to return only the 10 top rows from the authors table in the pubs database:
SET ROWCOUNT 10
GO
SELECT * FROM pubs.dbo.authors
GO
or
SELECT TOP 10 * FROM pubs.dbo.authors
for displaying the number for each record, I don\'t see any reason why would you wan to do, there are many different efficiant ways for this.
Post edited by: sanereddy, at: 2004/11/05 20:12
|