Источник: http://omnitrackerforum.org/forum/russian-omnitracker-forum/%D0%BF%D1%80%D0%B8%D0%BC%D0%B5%D1%80%D1%8B-%D1%80%D0%B5%D1%88%D0%B5%D0%BD%D0%B8%D0%B9/303-%D0%BE%D0%BF%D1%80%D0%B5%D0%B4%D0%B5%D0%BB%D0%B5%D0%BD%D0%B8%D0%B5-%D1%80%D0%B0%D0%B7%D0%BC%D0%B5%D1%80%D0%B0-%D1%82%D0%B0%D0%B1%D0%BB%D0%B8%D1%86-%D0%B2-%D0%B1%D0%B0%D0%B7%D0%B5-%D0%B4%D0%B0%D0%BD%D0%BD%D1%8B%D1%85-ms-sql-server
declare @t table (name varchar(255), [rows] varchar(255), reserved varchar(255), data varchar(255), index_size varchar(255), unused varchar(255))
delete from @t
insert into @t exec sp_MSforeachtable @command1='EXEC sp_spaceused ''?''',@whereand='or OBJECTPROPERTY(o.id, N''IsSystemTable'') = 1'
select
t.*
,CONVERT(bigint, REPLACE(data,' KB','')) / 1024 AS DataMb
,CONVERT(bigint, REPLACE(index_size,' KB','')) / 1024 AS indexMb
,CONVERT(bigint, REPLACE(reserved,' KB','')) / 1024 AS reservedMb
,CONVERT(bigint, REPLACE(unused,' KB','')) / 1024 AS unusedMb
from @t t
order by CONVERT(bigint,REPLACE(reserved,' KB','')) DESC
Комментариев нет:
Отправить комментарий