码迷,mamicode.com
首页 > 数据库 > 详细

Sql Server 2008查询数据库中各表记录行数

时间:2016-07-03 21:17:49      阅读:212      评论:0      收藏:0      [点我收藏+]

标签:

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查询数据库中各表记录行数

标签:

原文地址:http://www.cnblogs.com/jerron/p/5638656.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!