>我在表中有列[Type],其中包含枚举值(1,2,4,8 - 此数字的混合)。我需要为条件((类型和8)= 8)的2列创建唯一索引。
我试图这样做:
create unique index [name_unique] on [dbo].[Table]([Name],[SecondName],[Type]) WHERE (Type IN (9,10,12))
它可以工作,但是如果我需要向 Ennum 添加任何字段,我不想更改此索引。
为什么不使用按位运算符?
create unique index [name_unique] on [dbo].[Table]([Name], [SecondName], [Type])
where ( (AxisType & 8) > 0);