But how to get the number of records for all the tables in a database, if you use the above method to estimate the exhaustion. Oh
Here's how to use the sysindexes and sysobjects tables to get the number of records per table in a database:
First give the SQL Server 2000 version:
Copy Code code as follows:
SELECT O.name,
I.rowcnt
From sysindexes as I
INNER JOIN sysobjects as o on i.id = o.id
WHERE I.indid < 2
and OBJECTPROPERTY (o.id, ' ismsshipped ') = 0
ORDER BY O.name
SQL SERVER2005/8 version of SQL statement:
Copy Code code as follows:
SELECT O.name,
Ddps.row_count
From sys.indexes as I
INNER JOIN sys.objects as o on i.object_id = o.object_id
INNER JOIN sys.dm_db_partition_stats as DDPs on i.object_id = DDPs. object_id
and i.index_id = ddps.index_id
WHERE i.index_id < 2
and o.is_ms_shipped = 0
ORDER BY O.name
Try it quickly, and you'll get the same result as count (*).