Sql Server 2008查询数据库中各表记录行数
Posted jerron
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Sql Server 2008查询数据库中各表记录行数相关的知识,希望对你有一定的参考价值。
declare @low int , @unit varchar(10) , @val decimal(18,4)
set @unit = ‘KB‘
set @val = case when @unit = ‘KB‘ then 1024 when @unit = ‘MB‘ then 1024*1024 else 1 end
select @low = d.low from master.dbo.spt_values d
where d.number = 1 and d.type = ‘E‘
SELECT a.name, b.rows
, ltrim(str(b.reserved * @low / @val,15,0) + ‘ ‘ + @unit)
, ltrim(str(b.used * @low / @val ,15,0) + ‘ ‘ + @unit)
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
以上是关于Sql Server 2008查询数据库中各表记录行数的主要内容,如果未能解决你的问题,请参考以下文章