I encountered the situation recently where I needed to find the size of the log file, file location. Here is the script, if you remove the WHERE condition you will find the result for all the databases. 

Get Data file (.mdf) size of All Database

Get Log file (.ldf) size of All Database

Get all physical file size of All Database

N.B.:

  1. File_ID is file type. 1 for data file (*.mdf) and 2 for log file (*.ldf)
  2. State_Desc is file online or offline status.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.