我創建一個表中的一些過濾非羣集上的一些列,比如:過濾非聚集索引異常behaivior
CREATE UNIQUE NONCLUSTERED INDEX [IX_Sh_Esh] ON [dbo].[My_Tbl]
(
[City_Code] ASC,
[Sh_Esh] ASC
)
WHERE ([Sh_Bod]=(0) AND [Noe_Fa]=(0))
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
和:
CREATE UNIQUE NONCLUSTERED INDEX [IX_Kho] ON [dbo].[My_Tbl]
(
[City_Code] ASC,
[Kho] ASC
)
WHERE ([Sh_Bod]=(0) AND [Sh_Esh]=(0) AND [Noe_Fa]=(1))
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
我創造我的表這個指標與沒有錯誤,但當我想要添加一個新的列我得到這個錯誤:
'My_Tbl' table
- Unable to create index 'IX_Sh_Esh'.
The CREATE UNIQUE INDEX statement terminated because a duplicate key was found for the object name 'My_Tbl' and the index name 'IX_Sh_Esh'. The duplicate key value is (3, 0).
聲明已終止。
我的表中的數據是:
根據第一索引,因爲行1號和4號不滿足其中cluase不應該them.Why創建索引我得到上面的錯誤?
感謝
EDIT 1):
有有趣的點時,若我刪除索引,並添加列(軟件),然後重新創建索引,索引沒有error.STRANGE創造! !
表中只有6行? – JNK
沒有,還有更多的錯誤,但只顯示(3,0)爲複製 – Arian
所以你做了一個'SELECT * FROM dbo.My_Tbl WHERE CITY_CODE = 3,Sh_Esh = 0',看是否有其他行? – JNK