标签:
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
标签:
原文地址:http://www.cnblogs.com/jerron/p/5638656.html