Gess Man
Is there an easy way to count all records in a database
SQL Server Database Engine
Gess Man,
I fair one could be using sys.dm_db_partition_stats, if you are using SQL Server 2005. For 2000, use sysindexes, but execute "dbcc updateusage" before executing the "select" statement.
-- 2005
select
object_name([object_id]), sum(row_count) as row_cntfrom
sys.dm_db_partition_statswhere
objectproperty([object_id], 'IsUserTable') = 1group
by object_name([object_id])
-- 2000
dbcc updateusage('northwind')
go
select
object_name([id]),rowcnt
from
dbo
.sysindexeswhere
indid
in (0, 1) and objectproperty([id], 'IsUserTable') = 1
AMB
This is pretty easy:
EXEC
sp_msforeachtable 'sp_spaceused " "'