Created
August 17, 2022 08:27
-
-
Save ghotz/9bee625c09acca5082efbae31d2647b2 to your computer and use it in GitHub Desktop.
Get tempdb usage stats for all databases
This file contains hidden or 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
DROP TABLE IF EXISTS #tmp | |
CREATE TABLE #tmp | |
( | |
[database_name] [NVARCHAR](128) NULL, | |
[database_id] [INT] NULL, | |
[file_id] [SMALLINT] NULL, | |
[filegroup_id] [SMALLINT] NULL, | |
[total_page_count] [BIGINT] NULL, | |
[allocated_extent_page_count] [BIGINT] NULL, | |
[unallocated_extent_page_count] [BIGINT] NULL, | |
[version_store_reserved_page_count] [BIGINT] NULL, | |
[user_object_reserved_page_count] [BIGINT] NULL, | |
[internal_object_reserved_page_count] [BIGINT] NULL, | |
[mixed_extent_page_count] [BIGINT] NULL, | |
[modified_extent_page_count] [BIGINT] NULL | |
) | |
EXEC sp_msforeachdb N'USE [?]; INSERT INTO #tmp SELECT DB_NAME() as database_name, * FROM sys.dm_db_file_space_usage' | |
SELECT * FROM #tmp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment