August 5, 2003 at 3:37 am
I am using ADO in VC++ to access my SQL server database. How do I get the number of rows of a particular table in the database?
Thanks,
Krishnan
August 5, 2003 at 3:41 am
Hi Krishnan,
quote:
I am using ADO in VC++ to access my SQL server database. How do I get the number of rows of a particular table in the database?
you mean something like
iRetVal = recSet->GetRecourdCount(); ?
Cheers,
Frank
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
August 5, 2003 at 5:02 am
No, what I want is to now the number of rows(records) stored in a table, without executing a query to the database like SELECT * FROM CUSTOMERS. For eg, I want to know the number of customer records stored in the CUSTOMERS table. Is there any way to get this info?
BTW, I have found out one way and that is to use SELECT COUNT(*) from CUSTOMERS. But, I feel there must be a better and more efficient way to get the same result!
Thanks,
Krishnan
August 5, 2003 at 5:07 am
Hi Krishnan,
quote:
BTW, I have found out one way and that is to use SELECT COUNT(*) from CUSTOMERS. But, I feel there must be a better and more efficient way to get the same result!
I don't think that there is a more efficient way than SELECT COUNT(.), but if you come across one, I will be happy to know
Cheers,
Frank
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
August 5, 2003 at 6:06 am
You can use sp_spaceused @table_name which gives various bits of information about a table including the number of rows and is probably quicker than select count(*) from ....
However, it is not always accururate but you can correct the information with sp_spaceused <table_name>, 'TURE'. I forget when it gets out of sync with the actual table but I'm sure someone can remind me.
Jeremy
August 5, 2003 at 6:17 am
quote:
You can use sp_spaceused @table_name which gives various bits of information about a table including the number of rows and is probably quicker than select count(*) from ....However, it is not always accururate but you can correct the information with sp_spaceused <table_name>, 'TRUE'. I forget when it gets out of sync with the actual table but I'm sure someone can remind me.
sp_spaceused gets its data from (among other places) sysindexes. This data may be out of date if, for example, you've just deleted an index.
Thomas Rushton
blog: https://thelonedba.wordpress.com
August 5, 2003 at 9:11 am
Thank you guys I think this should work!
August 7, 2003 at 8:52 am
And thats like what it does:
select i.rows as [rows]
from sysindexes i
where i.indid < 2
and i.id = object_id('Customers')
Cheers.
August 7, 2003 at 6:41 pm
Exec sp_mstablespace <tablename>
paul
paul
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply