查找 SQL SERVER 所有表记录数

-- 所有表的记录数

SELECT a.name, b.rows
FROM sysobjects AS a INNER JOIN sysindexes AS b ON a.id = b.id
WHERE (a.type = 'u') AND (b.indid IN (0, 1))
ORDER BY b.rows DESC

-- 查找所有表的记录数以及空间占用情况

select
object_name(id) tablename,
8*reserved/1024 reserved,
rtrim(8*dpages)+'kb' used,
8*(reserved-dpages)/1024 unused,
8*dpages/1024-rows/1024*minlen/1024 free,
rows

from sysindexes
where indid=1
order by tablename,reserved desc

上一篇:什么是Linux主机?


下一篇:Thinkphp5笔记六:公共模块common的使用