Get SQL count into variable

  • Thread starter Thread starter Luke Davis
  • Start date Start date
L

Luke Davis

What is the quickest way to get the count of rows in a table into an int
variable?

for example how would I make this happen?


int remaining = SELECT Count(*) FROM states.dbo.cities
 
ADO.NET's .ExecuteScalar() method is designed for returning a single value.

-HTH
 

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

Back
Top