However, to obtain the number of records for all tables in a database, you would be exhausted by using the above method. Haha
The following describes how to use the sysindexes and sysobjects tables to obtain the number of records in each table of a database:
First, the SQL Server 2000 version is provided:
Copy codeThe Code is 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 statements of SQL Server2005/8:
Copy codeThe Code is 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. It must have the same result as your count.