Find current location of all data and log files of all databases of the server
While we can use GUI or sp_helpdb to find out all the data and log files of a specific database, below code will list all data and log files of all the databases housed on the SQL Server instance.
SELECT name, physical_name AS current_file_location
FROM sys.master_files
This can be a useful code to create and manage inventory or for some automation purpose.
Comments