If you ever need to know what is database name based on a data or transaction log file location, run the following T-SQL code.

select,, m.physical_name
from sys.master_files m
inner join sys.databases d
on (m.database_id = d.database_id)
where physical_name = N'D:\Data\datafile.mdf' --change the full path file
order by 1, 2


Comments are closed