List of databases with locations

  • Hi,

    I have found a script that returns a complete list of databases from a server but how do I get it to return the file path of the database also?

    Please help!

  • David,

    select * from sysdatabases

    will return you a lot of info including FilePath. But this path is only for the primary file. All other file locations: for the log files, for the secondary data files is in the sysfiles table in each database.

    Regards,Yelena Varsha

  • sp_MSForEachdb @command1='PRINT''[?]''', @command2='USE [?] EXEC sp_helpfile'

     

    This should loop through all databases and give file locations for each database file and log file for each database.

  • I think you meant to use sp_MSForEachDB instead of sp_MSForEachTable

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

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