Click here to Skip to main content
14,872,753 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi guy's

I have one question . how to retrive the table row cout in sql server? using asp.net,C# net,sql server.



Thank's & Regards.
Nagarajan P
Posted

See the Sql COUNT() function: W3Schools[^]
   
SQL
Select Count(*) TotalRows From TableName


This will return you the total number of rows in a table in SQL Server.
Create a procedure and use CommandObject.ExecuteScalar() method in ASP.NET to get the value in ASP.NET
   
Comments
avigodse 22-Mar-11 8:56am
   
Just a small modification there;
Select Count(0) TotalRows From TableName
Instead of using * use 0, it improves query performance.
Ankur\m/ 22-Mar-11 9:16am
   
I cannot find anything on the web (for SQL) which discusses this thing in detail.
So I am curious to know if there is considerate difference in the performance? Can you give me a link which discusses this thing in detail?
Thanks!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900