0
(0)

Below query can be used to get database data and log size details in SQL Server.

SELECT

db.name,

sum(case​​ when​​ [type]​​ =​​ 0​​ then​​ mf.size​​ *​​ 8​​ /​​ 1024​​ else​​ 0​​ end)​​ as​​ DataFileSizeMB,

sum(case​​ when​​ [type]​​ =​​ 1​​ then​​ mf.size​​ *​​ 8​​ /​​ 1024​​ else​​ 0​​ end)​​ as​​ LogFileSizeMB

from

sys.master_files​​ mf

join​​ sys.databases​​ db​​ on​​ db.database_id​​ =​​ mf.database_id

where​​ db.name​​ not​​ in('master','model','tempdb','msdb')​​ -- exclude system databases

group​​ by​​ db.name

order​​ by​​ DataFileSizeMB​​ desc

 

Output:

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.