top of page

SQL Server - Where do my SQL Database files reside?

Suppose you have multiple disks and databases. You might have a question where do my database files reside? The below script gives the directory of each database file.

(MDF\LDF\NDF) using the sys.master_files and sys.dm_os_volume_stats.

select name, volume_mount_point, logical_volume_name, 
file_system_type, physical_name, type_desc, state_desc
FROMsys.master_files ASf
CROSSAPPLY sys.dm_os_volume_stats(f.database_id, f.file_id);

253 views1 comment

1 Comment

Unknown member
Mar 31, 2023

Hey Raj, saw an article you wrote about filestream on sql server. If I don't have the files in the directory, can I recover them by restoring filestream table?

bottom of page