title | description | author | ms.author | ms.reviewer | ms.date | ms.service | ms.subservice | ms.topic | f1_keywords | helpviewer_keywords | dev_langs | ||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
sp_syspolicy_update_policy_category_subscription (Transact-SQL) |
Updates a policy category subscription for a specified database. |
VanMSFT |
vanto |
randolphwest |
06/26/2023 |
sql |
system-objects |
reference |
|
|
|
[!INCLUDE SQL Server]
Updates a policy category subscription for a specified database.
:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: Transact-SQL syntax conventions
sp_syspolicy_update_policy_category_subscription
[ @policy_category_subscription_id = ] policy_category_subscription_id
[ , [ @target_type = ] N'target_type' ]
[ , [ @target_object = ] N'target_object' ]
, [ @policy_category = ] N'policy_category'
[ ; ]
The identifier for the policy category subscription that you want to update. @policy_category_subscription_id is int, and is required.
The target type of the category subscription. @target_type is sysname, with a default of NULL
.
If you specify @target_type, the value must be set to DATABASE
.
The name of the database that will subscribe to the policy category. @target_object is sysname, with a default of NULL
.
The name of the policy category that you want the database to subscribe to. @policy_category is sysname, with a default of NULL
.
0
(success) or 1
(failure).
You must run sp_syspolicy_update_policy_category_subscription
in the context of the msdb
system database.
To obtain values for @policy_category_subscription_id and for @policy_category, you can use the following query:
SELECT a.policy_category_subscription_id,
a.target_type,
a.target_object,
b.name AS policy_category
FROM msdb.dbo.syspolicy_policy_category_subscriptions AS a
INNER JOIN msdb.dbo.syspolicy_policy_categories AS b
ON a.policy_category_id = b.policy_category_id;
Requires membership in the PolicyAdministratorRole fixed database role.
[!INCLUDE policy-administrator-role]
The following example updates an existing policy category subscription so that the [!INCLUDE sssampledbobject-md] database subscribes to the Finance
policy category.
EXEC msdb.dbo.sp_syspolicy_update_policy_category_subscription
@policy_category_subscription_id = 1,
@target_object = 'AdventureWorks2022',
@policy_category = 'Finance';
GO