get t-log names of all databases?

  • Hi. I have a table that has a column which contains names of all databases on the server.

    How can I find out transaction log name for every database in that table and add this as new column?

    Also, how can I iterate through that table and perform an action using that transaction log name as a parameter?

    Thanks in advance

  • Rambler (10/29/2010)


    Hi. I have a table that has a column which contains names of all databases on the server.

    How can I find out transaction log name for every database in that table and add this as new column?

    Also, how can I iterate through that table and perform an action using that transaction log name as a parameter?

    Thanks in advance

    What do you mean by transaction log name? Do you mean the file name of the transaction log file(s)? You can get this or these from each database as follows:

    SELECT [name] FROM sys.database_files

    WHERE type_desc = 'LOG'

    You can use a cursor to run this on every database, you can use the undocumented stored procedure sp_MSforeachdatabase, or you can generate the SQL to run it for all databases.

    What action do you want to perform using the transaction log names as a parameter?

    John

  • Rambler (10/29/2010)


    Hi. I have a table that has a column which contains names of all databases on the server.

    How can I find out transaction log name for every database in that table and add this as new column?

    select name,physical_name from sys.master_files

    where type=1

    Also, how can I iterate through that table and perform an action using that transaction log name as a parameter?

    what action do you want to perform?



    Pradeep Singh

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

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