sys.dm_clr_tasks (Transact-SQL)

APPLIES TO: YesSQL Server YesAzure SQL Database NoAzure Synapse Analytics (SQL DW) NoParallel Data Warehouse

Returns a row for all common language runtime (CLR) tasks that are currently running. A Transact-SQL batch that contains a reference to a CLR routine creates a separate task for execution of all the managed code in that batch. Multiple statements in the batch that require managed code execution use the same CLR task. The CLR task is responsible for maintaining objects and state pertaining to managed code execution, as well as the transitions between the instance of SQL Server and the common language runtime.

Column name Data type Description
task_address varbinary(8) Address of the CLR task.
sos_task_address varbinary(8) Address of the underlying Transact-SQL batch task.
appdomain_address varbinary(8) Address of the application domain in which this task is running.
state nvarchar(128) Current state of the task.
abort_state nvarchar(128) State the abort is currently in (if the task was canceled) There are multiple states involved while aborting tasks.
type nvarchar(128) Task type.
affinity_count int Affinity of the task.
forced_yield_count int Number of times the task was forced to yield.


On SQL Server, requires VIEW SERVER STATE permission.
On SQL Database Premium Tiers, requires the VIEW DATABASE STATE permission in the database. On SQL Database Standard and Basic Tiers, requires the Server admin or an Azure Active Directory admin account.

See Also

Dynamic Management Views and Functions (Transact-SQL)
Common Language Runtime Related Dynamic Management Views (Transact-SQL)