Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 count question

Author  Topic 

csphard
Posting Yak Master

113 Posts

Posted - 2002-04-30 : 20:27:19
how can i combine the following. I would like to get a total count as well as the actual records.


select count(*) from categories

select * from categories

jbkayne
Posting Yak Master

100 Posts

Posted - 2002-04-30 : 21:08:12
select *, (select count(*) from categories) as TotalCount
from categories

Go to Top of Page

Paulo
Starting Member

3 Posts

Posted - 2002-05-03 : 18:15:14
If you want to avoid using a subquery, you can do this:

select *, @@rowcount as MyRows from categories.

This will be a little more efficient.
Go to Top of Page

Paulo
Starting Member

3 Posts

Posted - 2002-05-03 : 18:29:09
DOH! My bad - ignore my previous post.

Go to Top of Page
   

- Advertisement -