• Hi,

    You can utilize the following steps:

    1. Create your conditions which you want to evaluate.

    2. Create a second condition that makes use of the "Database" facet. In this condition, you should use @Name and the databases you want to exclude the databases.

    3. Create your policy, you will see a drop down for databases which says "every". Drop this down and select your condition to do the exclusion of the names.

    Execute the below script to see an example.

    Declare @object_set_id int

    EXEC msdb.dbo.sp_syspolicy_add_object_set @object_set_name=N'test_ObjectSet_1', @facet=N'IDatabaseMaintenanceFacet', @object_set_id=@object_set_id OUTPUT

    Select @object_set_id

    Declare @target_set_id int

    EXEC msdb.dbo.sp_syspolicy_add_target_set @object_set_name=N'test_ObjectSet_1', @type_skeleton=N'Server/Database', @type=N'DATABASE', @enabled=True, @target_set_id=@target_set_id OUTPUT

    Select @target_set_id

    EXEC msdb.dbo.sp_syspolicy_add_target_set_level @target_set_id=@target_set_id, @type_skeleton=N'Server/Database', @level_name=N'Database', @condition_name=N'db_name', @target_set_level_id=0

    GO

    Declare @policy_id int

    EXEC msdb.dbo.sp_syspolicy_add_policy @name=N'test', @condition_name=N'backup date', @policy_category=N'', @description=N'', @help_text=N'', @help_link=N'', @schedule_uid=N'00000000-0000-0000-0000-000000000000', @execution_mode=0, @is_enabled=False, @policy_id=@policy_id OUTPUT, @root_condition_name=N'', @object_set=N'test_ObjectSet_1'

    Select @policy_id

    GO

    Unfortunately you have to specify multiple databases, as the check target does not seem to support the Array function which the NOT IN operator supports.

    Don't hesitate to ask any other questions.

    If you are interested in Policy Based Management, you can get a book called Pro: SQL Server 2008 Policy Based Management written by Ken Simmons.

    Regards...