Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f72fd58

Browse files
committed
Add Get_Database_Size_With_Graph script
1 parent 8946f80 commit f72fd58

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
Author: Denis Gobo
3+
Original link: http://sqlservercode.blogspot.ru/2017/11/use-t-sql-to-create-caveman-graphs.html
4+
*/
5+
6+
SELECT database_name = DB_NAME(database_id)
7+
, TotalSizeGB = CAST(SUM(size) * 8.0 / 1024/1024 AS DECIMAL(30,2))
8+
, PercentSize = (CONVERT(decimal(30,4), (SUM(size) /
9+
(SELECT SUM(CONVERT(decimal(30,4),size))
10+
FROM sys.master_files WITH(NOWAIT)))
11+
) * 100.00)
12+
, Graph = replicate('|', ((convert(decimal(30,2), (SUM(size) /
13+
(SELECT SUM(CONVERT(decimal(30,2),size))
14+
FROM sys.master_files WITH(NOWAIT)))) * 100)
15+
)
16+
)
17+
FROM sys.master_files WITH(NOWAIT)
18+
GROUP BY database_id
19+
ORDER BY PercentSize DESC;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /