Share via


sp_syspolicy_update_policy_category_subscription (Transact-SQL)

更新指定之資料庫的原則類別目錄訂閱。

主題連結圖示Transact-SQL 語法慣例

語法

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
    這是您想要更新之原則類別目錄訂閱的識別碼。policy_category_subscription_id 是 int,而且為必要項目。

  • [ @target_type= ] 'target_type'
    這是類別目錄訂閱的目標類型。target_type 是 sysname,且預設值為 NULL。

    如果您指定 target_type,此值必須設定為 'DATABASE'。

  • [ @target_object= ] 'target_object'
    這是將要訂閱此原則類別目錄的資料庫名稱。 target_object 是 sysname,而且預設值為 NULL。

  • [ @policy_category= ] 'policy_category'
    這是您希望資料庫訂閱的原則類別目錄名稱。 policy_category 是 sysname,而且預設值為 NULL。

傳回碼值

0 (成功) 或 1 (失敗)

備註

您必須在 msdb 系統資料庫的內容中執行 sp_syspolicy_update_policy_category_subscription。

若要取得 policy_category_subscription_id 和 policy_category 的值,您可以使用下列查詢:

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

權限

需要 PolicyAdministratorRole 固定資料庫角色中的成員資格。

安全性注意事項安全性注意事項

可能會提高認證:PolicyAdministratorRole 角色中的使用者可以建立伺服器觸發程序以及排程可能會影響 Database Engine 執行個體作業的原則執行。例如,PolicyAdministratorRole 角色中的使用者可以建立防止在 Database Engine 中建立大部分物件的原則。由於可能會提高認證,因此 PolicyAdministratorRole 角色應該只授與可控制 Database Engine 組態的受信任使用者。

範例

下列範例會更新現有的原則類別目錄訂閱,好讓 AdventureWorks 資料庫訂閱 'Finance' 原則類別目錄。

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

GO