sp_syspolicy_update_policy_category_subscription (Transact-SQL)

Updates a policy category subscription for a specified database.

Topic link iconTransact-SQL Syntax Conventions

sp_syspolicy_update_policy_category_subscription [ @policy_category_subscription_id= ] policy_category_subscription_id
    [ , [ @target_type = ] 'target_type' ]
    [ , [ @target_object= ] 'target_object' ]
    , [ @policy_category= ] 'policy_category'

[ @policy_category_subscription_id= ] policy_category_subscription_id

Is the identifier for the policy category subscription that you want to update. policy_category_subscription_id is int, and is required.

[ @target_type= ] 'target_type'

Is 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'.

[ @target_object= ] 'target_object'

Is the name of the database that will subscribe to the policy category. target_object is sysname, with a default of NULL.

[ @policy_category= ] 'policy_category'

Is 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.

Security noteSecurity Note

Possible elevation of credentials: Users in the PolicyAdministratorRole role can create server triggers and schedule policy executions that can affect the operation of the instance of the Database Engine. For example, users in the PolicyAdministratorRole role can create a policy that can prevent most objects from being created in the Database Engine. Because of this possible elevation of credentials, the PolicyAdministratorRole role should be granted only to users who are trusted with controlling the configuration of the Database Engine.

The following example updates an existing policy category subscription so that the AdventureWorks database subscribes to the 'Finance' policy category.

EXEC msdb.dbo.sp_syspolicy_update_policy_category_subscription @policy_category_subscription_id = 1
, @target_object = 'AdventureWorks'
, @policy_category = 'Finance';


Community Additions