Introduction
I faced a situation where I needed to find the size of the log file. What was happening was that my database size was growing very large, so I wanted to see the size of my mdf and ldf file. I wrote a simple select
statement to get it.
SELECT DB_NAME(database_id) AS DBName,Name AS Logical_Name, Physical_Name,(size*8)/1024 SizeMB
FROM sys.master_files
WHERE DB_NAME(database_id) = 'MyTestDB'
If we remove the WHERE
condition, we will get the result for all the databases including system default database.
SELECT DB_NAME(database_id) AS DBName,Name AS Logical_Name,Physical_Name,(size*8)/1024 SizeMB
FROM sys.master_files
Points of Interest
We can do complex things in a simple manner.