DROP WORKLOAD GROUP (Transact-SQL)

Select a product

In the following row, select the product name you're interested in, and only that product's information is displayed.

* SQL Server *  

 

SQL Server and SQL Managed Instance

Drops an existing user-defined resource governor workload group.

Note

For Azure SQL Managed Instance, you must be in the context of the master database to modify resource governor configuration.

Transact-SQL syntax conventions.

Syntax

DROP WORKLOAD GROUP group_name
[;]

Arguments

group_name

The name of an existing user-defined workload group.

Remarks

The DROP WORKLOAD GROUP statement is not allowed on the resource governor built-in internal and default groups.

If a workload group contains active sessions, deleting the workload group fails when the ALTER RESOURCE GOVERNOR RECONFIGURE statement is executed to apply the change. To avoid this problem, you can take one of the following actions:

  • Wait until all sessions in the affected group disconnect, and then execute the ALTER RESOURCE GOVERNOR RECONFIGURE statement.
  • Explicitly stop sessions in the affected group by using the KILL T-SQL command, and then execute the ALTER RESOURCE GOVERNOR RECONFIGURE statement. If you decide that you don't want to explicitly stop sessions, re-create the group by using the original name and settings.
  • Restart the server. When the server restarts, the deleted group is deleted permanently.

For more information, see Resource governor and Resource governor workload group.

Permissions

Requires the CONTROL SERVER permission.

Examples

The following example drops the workload group named adhoc.

DROP WORKLOAD GROUP adhoc;

ALTER RESOURCE GOVERNOR RECONFIGURE;

* SQL Managed Instance *  

 

SQL Server and SQL Managed Instance

Drops an existing user-defined resource governor workload group.

Note

For Azure SQL Managed Instance, you must be in the context of the master database to modify resource governor configuration.

Transact-SQL syntax conventions.

Syntax

DROP WORKLOAD GROUP group_name
[;]

Arguments

group_name

The name of an existing user-defined workload group.

Remarks

The DROP WORKLOAD GROUP statement is not allowed on the resource governor built-in internal and default groups.

If a workload group contains active sessions, deleting the workload group fails when the ALTER RESOURCE GOVERNOR RECONFIGURE statement is executed to apply the change. To avoid this problem, you can take one of the following actions:

  • Wait until all sessions in the affected group disconnect, and then execute the ALTER RESOURCE GOVERNOR RECONFIGURE statement.
  • Explicitly stop sessions in the affected group by using the KILL T-SQL command, and then execute the ALTER RESOURCE GOVERNOR RECONFIGURE statement. If you decide that you don't want to explicitly stop sessions, re-create the group by using the original name and settings.
  • Restart the server. When the server restarts, the deleted group is deleted permanently.

For more information, see Resource governor and Resource governor workload group.

Permissions

Requires the CONTROL SERVER permission.

Examples

The following example drops the workload group named adhoc.

DROP WORKLOAD GROUP adhoc;

ALTER RESOURCE GOVERNOR RECONFIGURE;

* Azure Synapse
Analytics *
 

 

Azure Synapse Analytics

Drops a workload group. Once the statement completes, the settings are in effect.

Transact-SQL syntax conventions

Syntax

DROP WORKLOAD GROUP group_name  

Arguments

group_name
Is the name of an existing user-defined workload group.

Remarks

A workload group cannot be dropped if classifiers exist for the workload group. Drop the classifiers before the workload group is dropped. If there are active requests using resources from the workload group being dropped, the drop workload statement is blocked behind them.

Examples

Use the following code example to determine which classifiers need to be dropped before the workload group can be dropped.

SELECT c.name as classifier_name
      ,'DROP WORKLOAD CLASSIFIER '+c.name as drop_command
  FROM sys.workload_management_workload_classifiers c
  JOIN sys.workload_management_workload_groups g
    ON c.group_name = g.name
  WHERE g.name = 'wgXYZ' --change the filter to the workload being dropped

Permissions

Requires CONTROL DATABASE permission