TSQL to find the database for a given log file name

  • I have some log files that haven't been modified in quite some time. My question is, if I have the name of just the log file, is there a query that can return the name of the database that uses it?

    sort of like

    select databasename from SomeWhere

    Where databaseLogFile = 'The Log File Name Goes Here'

  • select db_name(database_id),physical_name from sys.master_files

    All the information you need is in that table. [name] is the logical file name. If you're looking for a specific filename, look in [physical_name].

    ______________________________________________________________________________________________
    Forum posting etiquette.[/url] Get your answers faster.

  • Keep in mind that dbs can be dettached so before deleting something make REALLLLLLLLLLY sure it's not needed anymore... and even then burn it cd/dvd if possible.

  • excellent reminder

    ______________________________________________________________________________________________
    Forum posting etiquette.[/url] Get your answers faster.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply