Database File Locations

Here is a SQL Script to get database file locations.
This helps to locate the actual location of the database files on the physical drives.

This comes in handy when you are planning to do any database migrations to another server and to get an understanding of the database file locations.

I use this script a lot specially when I am preparing for a SQL Server upgrade or migration to get a better idea on where the database files are located, which drives are on the server and it is being used by the SQL Server Engine. Having this information helps me better plan for my migration and upgrade plans.

USE master;
  name 'Logical Name', 
  physical_name 'File Location'
FROM sys.master_files;