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


18 Responses

  1. join with sys.databases is not needed here
    use db_name(database_id) function to get database name

  2. 1Learn more about how to get free gems on cooking fever

    This game is a whole lot more fun when you have as many gems as you could ever want.If you like mobile games like this you ought to check out this link

  3. 100,000 Backlinks only $10,Subject to data from paid $10 by PayPal (My,Tell me your URL, email and comment content.I will complete the task within ten days.But It may take up to a month for the data updated from

Leave a Reply

Your email address will not be published. Required fields are marked *