This is a discussion on Row count in sqlserver within the SQL Server 2005 Tutorials forums, part of the Articles and Tutorials category; Hello, How we can find the rowcount in sqlserver. I have 10 rows displayed, I want to get numbering for ...
|
|||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Row count in sqlserver
Hello,
How we can find the rowcount in sqlserver. I have 10 rows displayed, I want to get numbering for the rows.ie 1 to 10. Please clarify it. Regards Pramod Post edited by: pramodm, at: 2004/11/05 16:56 |
|
|||
|
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 |