Use msdb
SELECT
DB_NAME() AS 'Database'
,e.tSize AS 'Size(MB)'
,SUM(used_page_count)*8 /1024.0 AS 'Used(MB)'
,e.tSize-SUM(used_page_count)*8 /1024.0 AS 'Free(MB)'
,cast((SUM(used_page_count)*8/1024.0)*100/e.tSize AS DECIMAL(10,2))AS '사용량(%)'
FROM sys.objects AS a JOIN sys.dm_db_partitiON_stats AS b
ON a.object_id = b.object_id
JOIN sys.sysindexes AS c
ON a.object_id = c.id
AND b.index_id = c.indid
JOIN sys.filegroups AS d
ON c.groupid = d.data_space_id
JOIN (SELECT data_space_id,SUM(size)*8/1024.0 AS 'tSize'
FROM sys.databASe_files WHERE data_space_id <> 0 GROUP BY data_space_id) AS e
ON d.data_space_id = e.data_space_id
GROUP BY d.name,c.groupid,e.tSize
DB_NAME() AS 'Database'
,e.tSize AS 'Size(MB)'
,SUM(used_page_count)*8 /1024.0 AS 'Used(MB)'
,e.tSize-SUM(used_page_count)*8 /1024.0 AS 'Free(MB)'
,cast((SUM(used_page_count)*8/1024.0)*100/e.tSize AS DECIMAL(10,2))AS '사용량(%)'
FROM sys.objects AS a JOIN sys.dm_db_partitiON_stats AS b
ON a.object_id = b.object_id
JOIN sys.sysindexes AS c
ON a.object_id = c.id
AND b.index_id = c.indid
JOIN sys.filegroups AS d
ON c.groupid = d.data_space_id
JOIN (SELECT data_space_id,SUM(size)*8/1024.0 AS 'tSize'
FROM sys.databASe_files WHERE data_space_id <> 0 GROUP BY data_space_id) AS e
ON d.data_space_id = e.data_space_id
GROUP BY d.name,c.groupid,e.tSize
이것저것 찾아봤는데,
이것처럼 맨 위에
use DB 이름 적은 것만 말고,
SQLServer 안에 있는 모든 DB 에 대해서
아래 내용처럼 쿼리하고싶은데 방법이 있을까요? ㅠㅠ
오늘 날이 춥습니다 감기 조심하세요~
Comment 1
-
초짜해커
2016.11.07 13:20
http://chozzahacker.blogspot.com/2014/04/DatabaseSizeInfo.html