Created
February 20, 2024 00:37
-
-
Save petesql/5d7d6ee5bd0e8cd77802b4ff52fb68f5 to your computer and use it in GitHub Desktop.
SQL Server Get Database File Information
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
-- Get db filenames, paths, sizes and growth info | |
SELECT DB_NAME(database_id) AS 'Database Name', | |
file_id, name, physical_name, type_desc, state_desc, | |
is_percent_growth, growth, | |
CONVERT(bigint, growth/128.0) AS 'Growth in MB', | |
CONVERT(bigint, size/128.0) AS 'Total Size in MB', max_size | |
FROM sys.master_files WITH (NOLOCK) | |
ORDER BY DB_NAME(database_id), file_id OPTION (RECOMPILE); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment