Unable to create UNIQUE Filtered index with IGNORE_DUP_KEY = ON
As already mentioned by the other answer, IGNORE_DUP_KEY is not supported for filtered indexes, which is explicitly stated in the manual:


  Filtered indexes do not allow the IGNORE_DUP_KEY option.


There is a workaround, however, if you can afford a small change to the table's structure. With the help of a uniquifier column you can create a unique index that would effectively allow you to have unique Values only for rows with FLAG = 1.

The following assumes that the ID column is already declared as unique (either being the primary key or having a UNIQUE constraint on it). First, add a computed column that would evaluate to NULL for the FLAG = 1 rows and to ID for all the others:

ALTER TABLE dbo.FOO
ADD Uniquifier AS CASE FLAG WHEN 1 THEN NULL ELSE ID END;


Now you can create a unique index on (Value, Uniquifier) with the IGNORE_DUP_KEY option:

CREATE UNIQUE NONCLUSTERED INDEX UQ_1
ON dbo.FOO (Value, Uniquifier)
WITH (IGNORE_DUP_KEY = ON);


Since Uniquifier will be NULL for rows with FLAG = 1, the uniqueness will be determined based on Value alone. All the other rows will be unique regardless of Value because Uniquifier is unique (since its value is taken from a unique column, ID).

A live demonstration of the method is available at SQL Fiddle.