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,C# net,sql server.

Thank's & Regards.
Nagarajan P

See the Sql COUNT() function: W3Schools[^]
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
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?

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