﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2008 / SQL Server 2008 - General  / 'not in' condition in Policy Based / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Mon, 20 May 2013 14:31:36 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: 'not in' condition in Policy Based</title><link>http://www.sqlservercentral.com/Forums/Topic1185749-391-1.aspx</link><description>Use Array function in the Value filed of the condition.Eg:Array("master", "model", "msdb")That works for me.</description><pubDate>Thu, 10 Jan 2013 05:25:30 GMT</pubDate><dc:creator>Vedran Kesegic</dc:creator></item><item><title>RE: 'not in' condition in Policy Based</title><link>http://www.sqlservercentral.com/Forums/Topic1185749-391-1.aspx</link><description>Thanks for your response, unfortunately I have only worked through the GUI so don't understand much of what is in your scripts as they don't appear to match what is created by the 'script' button within the GUI.I do have two 'conditions', one for the test I wish to make and one for the databases I wish to exclude. These are referenced in a Policy as you describe. The problem I have is the 'Condition' for the databases I wish to exclude. Currently I have this set to use a 'not like' clause for a single string. When I script this it shows [code="other"]Declare @condition_id intEXEC msdb.dbo.sp_syspolicy_add_condition @name=N'Exclude databases', @description=N'', @facet=N'Database', @expression=N'&amp;lt;Operator&amp;gt;  &amp;lt;TypeClass&amp;gt;Bool&amp;lt;/TypeClass&amp;gt;  &amp;lt;OpType&amp;gt;NOT_LIKE&amp;lt;/OpType&amp;gt;  &amp;lt;Count&amp;gt;2&amp;lt;/Count&amp;gt;  &amp;lt;Attribute&amp;gt;    &amp;lt;TypeClass&amp;gt;String&amp;lt;/TypeClass&amp;gt;    &amp;lt;Name&amp;gt;Name&amp;lt;/Name&amp;gt;  &amp;lt;/Attribute&amp;gt;  &amp;lt;Constant&amp;gt;    &amp;lt;TypeClass&amp;gt;String&amp;lt;/TypeClass&amp;gt;    &amp;lt;ObjType&amp;gt;System.String&amp;lt;/ObjType&amp;gt;    &amp;lt;Value&amp;gt;%AuditLog2%&amp;lt;/Value&amp;gt;  &amp;lt;/Constant&amp;gt;&amp;lt;/Operator&amp;gt;', @is_name_condition=4, @obj_name=N'%AuditLog2%', @condition_id=@condition_id OUTPUTSelect @condition_idGO[/code]I can not make out how to change this for a 'NOT IN' condition with an array of database names, which is what I am trying to achieve.</description><pubDate>Wed, 05 Oct 2011 06:35:18 GMT</pubDate><dc:creator>PAH-440118</dc:creator></item><item><title>RE: 'not in' condition in Policy Based</title><link>http://www.sqlservercentral.com/Forums/Topic1185749-391-1.aspx</link><description>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.[code="sql"]Declare @object_set_id intEXEC msdb.dbo.sp_syspolicy_add_object_set @object_set_name=N'test_ObjectSet_1', @facet=N'IDatabaseMaintenanceFacet', @object_set_id=@object_set_id OUTPUTSelect @object_set_idDeclare @target_set_id intEXEC 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 OUTPUTSelect @target_set_idEXEC 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=0GODeclare @policy_id intEXEC 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_idGO[/code]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...</description><pubDate>Wed, 05 Oct 2011 04:30:45 GMT</pubDate><dc:creator>SQLArcher</dc:creator></item><item><title>'not in' condition in Policy Based</title><link>http://www.sqlservercentral.com/Forums/Topic1185749-391-1.aspx</link><description>Using Policy Based Management, I am creating a policy to fine databases which have not had a FULL or Incremental Backup in the last 24hrs. This works OK but I need to ad a condition to the targets so that some databases (temporary copies etc) can be excluded. I can do this for a single database setting a condition with the expression: @name != '&amp;lt;DatabaseName&amp;gt;', however I want to add a series of databases to this. I thought the way to do this would be to use the 'NOT IN' operator, However I can not format the Value field to accept multiple values (Screenshots attached)Please can anyone provide an example of how to format this</description><pubDate>Wed, 05 Oct 2011 04:04:03 GMT</pubDate><dc:creator>PAH-440118</dc:creator></item></channel></rss>