Count number of records/tuples in a database

  • Thread starter Thread starter weird0
  • Start date Start date
W

weird0

What is the best way to count the number of records in a MS SQL DB.
The way I do it is executeReader() and loop through all the records in
a db and increment variable RowCount++.

Is there already a function pre-defined for it ?
 
weird0 said:
What is the best way to count the number of records in a MS SQL DB.
The way I do it is executeReader() and loop through all the records in
a db and increment variable RowCount++.

Is there already a function pre-defined for it ?

There sure is. Use the count() aggregate in a query:

"select count(*) from SomeTable"

This will return one row that contains the number of records in the table.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top