Warning: Undefined variable $ub in /home/sgso7sed/public_html/wp-content/plugins/advanced-page-visit-counter/public/class-advanced-page-visit-counter-public.php on line 148

Warning: Undefined variable $ub in /home/sgso7sed/public_html/wp-content/plugins/advanced-page-visit-counter/public/class-advanced-page-visit-counter-public.php on line 160
Find a DB name based on a file location SQL Server Monitoring • SQL Server

Categories:

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 d.name, m.name, 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

Tags:

Comments are closed