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)
 Number of Lines

Author  Topic 

Superr
Starting Member

2 Posts

Posted - 2005-12-07 : 15:39:09
Hi, I'm new to MS SQL Server and I'd like to know if there is a system table that has the number of lines for each table of one Database!

Thk

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2005-12-07 : 16:22:40
>>number of lines for each table

what do you mean by this? Do you mean the row count? As in, how many rows of data each table contains?

If so, what I usually do for a given table is:
select rowcnt from sysindexes where object_name(id) = '<myTableName>' and indid < 2

This assumes the table has a primary key and I don't know if the result is accurate 100% of the time. It's just a faster alternative to "select count(*) from <myTable>"

Be One with the Optimizer
TG
Go to Top of Page

blindman
Master Smack Fu Yak Hacker

2365 Posts

Posted - 2005-12-07 : 16:46:27
I don't think this is accurate unless you run a call to DBCC UPDATEUSAGE first, and that would end up blowing out any efficiency gain. If you just need round numbers, then go ahead and use the technique mentioned above, but if you have to have accuracy then go with select count(*).
Go to Top of Page

Superr
Starting Member

2 Posts

Posted - 2005-12-07 : 16:48:51
Thank You! ;)
It worked :D
Go to Top of Page
   

- Advertisement -