How do I get a query to count the total lines?

advertisements

How to get a query to count the total rows? My query:


How about

SELECT COUNT(*)
FROM dbo.WhateverYourTableIsCalled

Update: since this is a query output, you need to use

SELECT COUNT(*)
FROM
     (...your current query here....)

or just call

SELECT @@ROWCOUNT

after you've selected the data.