June 11, 2012

sp_syspolicy_unsubscribe_from_policy_category (Transact-SQL MetaData) Definition

Please note: that the following source code is provided and copyrighted by Microsoft and is for educational purpose only.
The meta data is from an SQL 2012 Server.

I have posted alot more, find the whole list here.

Goto Definition or MetaData

Definition:

sys.sp_syspolicy_unsubscribe_from_policy_category(nvarchar @policy_category)

MetaData:

 CREATE PROCEDURE sys.sp_syspolicy_unsubscribe_from_policy_category  
@policy_category sysname
AS
BEGIN
IF( @policy_category IS NULL)
BEGIN
RAISERROR(14043, -1, -1, '@policy_category', 'sp_syspolicy_unsubscribe_from_policy_category')
RETURN(1)
END

IF (IS_MEMBER('db_owner') != 1)
BEGIN
RAISERROR(21050, -1, -1)
RETURN(1)
END
DECLARE @policy_category_subscription_id INT
SET @policy_category_subscription_id =
(SELECT policy_category_subscription_id
FROM [msdb].[dbo].[syspolicy_policy_category_subscriptions] pgs
INNER JOIN [msdb].[dbo].[syspolicy_policy_categories] pg
ON pgs.policy_category_id = pg.policy_category_id
WHERE pgs.target_type = N'DATABASE' AND
pgs.target_object = DB_NAME() AND
pg.name = @policy_category)

EXEC [msdb].[dbo].[sp_syspolicy_delete_policy_category_subscription] @policy_category_subscription_id
END

No comments:

Post a Comment

Total Pageviews