Created
February 5, 2018 20:19
-
-
Save chrisg32/58ec7e45375e5a7e02365ccf58cf4f70 to your computer and use it in GitHub Desktop.
Lists the SQL Server databases and their corresponding file locations.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT db.[name], mdf.[physical_name] AS [Data File], ldf.[physical_name] AS [Log File] | |
FROM [master].[sys].[databases] db | |
INNER JOIN [master].[sys].[master_files] mdf ON db.[database_id] = mdf.[database_id] AND mdf.[type] = 0 | |
INNER JOIN [master].[sys].[master_files] ldf ON db.[database_id] = ldf.[database_id] AND ldf.[type] = 1 | |
--WHERE lower(mdf.[physical_name]) LIKE 'c%' OR lower(ldf.[physical_name]) LIKE 'c%' | |
ORDER BY db.[name] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment