System dynamic management views
Applies to: SQL Server Azure SQL Database Azure SQL Managed Instance Azure Synapse Analytics Analytics Platform System (PDW) SQL analytics endpoint in Microsoft Fabric Warehouse in Microsoft Fabric
Dynamic management views (DMVs) and dynamic management functions (DMFs) return server state information that can be used to monitor the health of a server instance, diagnose problems, and tune performance.
Important
Dynamic management views and functions return internal, implementation-specific state data. Their schemas and the data they return may change in future releases of SQL Server. Therefore, dynamic management views and functions in future releases may not be compatible with the dynamic management views and functions in this release. For example, in future releases of SQL Server, Microsoft may augment the definition of any dynamic management view by adding columns to the end of the column list. We recommend against using the syntax SELECT * FROM dynamic_management_view_name
in production code because the number of columns returned might change and break your application.
There are two types of dynamic management views and functions:
Server-scoped dynamic management views and functions. These require VIEW SERVER STATE permission on the server. For SQL Server 2022 and later, VIEW SERVER PERFORMANCE STATE is required, or VIEW SERVER SECURITY STATE is required for a few DMVs that are security related.
Database-scoped dynamic management views and functions. These require VIEW DATABASE STATE permission on the database. For SQL Server 2022 and later, VIEW DATABASE PERFORMANCE STATE is required, or VIEW DATABASE SECURITY STATE is required for a few DMVs that are security related.
Query dynamic management views
Dynamic management views can be referenced in Transact-SQL statements by using two-part, three-part, or four-part names. Dynamic management functions on the other hand can be referenced in Transact-SQL statements by using either two-part or three-part names. Dynamic management views and functions can't be referenced in Transact-SQL statements by using one-part names.
All dynamic management views and functions exist in the sys schema and follow this naming convention dm_*. When you use a dynamic management view or function, you must prefix the name of the view or function by using the sys schema. For example, to query the dm_os_wait_stats dynamic management view, run the following query:
SELECT wait_type, wait_time_ms
FROM sys.dm_os_wait_stats;
Required permissions
To query a dynamic management view or function requires SELECT permission on object and VIEW SERVER STATE or VIEW DATABASE STATE permission. This lets you selectively restrict access of a user or login to dynamic management views and functions. To do this, first create the user in master
and then deny the user SELECT permission on the dynamic management views or functions that you don't want them to access. After this, the user can't select from these dynamic management views or functions, regardless of database context of the user.
Note
Because DENY takes precedence, if a user has been granted VIEW SERVER STATE permissions but denied VIEW DATABASE STATE permission, the user can see server-level information, but not database-level information.
In this section
Dynamic management views and functions have been organized into the following categories.
Always On Availability Groups Dynamic Management Views - Functions
Change Data Capture - sys.dm_cdc_errors
Change Tracking - sys.dm_tran_commit_table
Common Language Runtime Related Dynamic Management Views (Transact-SQL)
Database Mirroring - sys.dm_db_mirroring_auto_page_repair
Database related dynamic management views (Transact-SQL)
Execution Related Dynamic Management Views and Functions (Transact-SQL)
Extended Events Dynamic Management Views
FILESTREAM and FileTable dynamic management views (Transact-SQL)
Full-Text and Semantic Search Dynamic Management Views - Functions
Geo-Replication Dynamic Management Views and Functions (Azure SQL Database)
Index Related Dynamic Management Views and Functions (Transact-SQL)
I/O Related Dynamic Management Views and Functions (Transact-SQL)
Memory-Optimized Table Dynamic Management Views (Transact-SQL)
Object Related Dynamic Management Views and Functions (Transact-SQL)
Query Notifications - sys.dm_qn_subscriptions
Replication Related Dynamic Management Views (Transact-SQL)
Resource Governor Related Dynamic Management Views (Transact-SQL)
Security-Related Dynamic Management Views and Functions (Transact-SQL)
Server dynamic management views and functions (Transact-SQL)
Service Broker Related Dynamic Management Views (Transact-SQL)
Spatial Data - sys.dm_db_objects_disabled_on_compatibility_level_change
SQL and Parallel Data Warehouse Dynamic Management Views
SQL Server Operating System Related Dynamic Management Views (Transact-SQL)
Stretch Database related dynamic management views (Transact-SQL)
Transaction Related Dynamic Management Views and Functions (Transact-SQL)