問題描述
我嘗試對 SQL Server 2005 中的表創建非唯一索引.嘗試創建它時出現以下錯誤.
I trying to and a non-unique index to a table table in SQL Server 2005. I am getting the following error when I try to create it.
消息 1505,級別 16,狀態 1,第 1 行CREATE UNIQUE INDEX 語句終止,因為找到了對象名稱dbo.oe_pick_ticket"和索引名稱idx_pick_ticket_popup_wmms"的重復鍵.重復鍵值為 (1093066, N, N, N, , FBF, 100001, 1074359, 1118930).
Msg 1505, Level 16, State 1, Line 1 The CREATE UNIQUE INDEX statement terminated because a duplicate key was found for the object name 'dbo.oe_pick_ticket' and the index name 'idx_pick_ticket_popup_wmms'. The duplicate key value is (1093066, N, N, N, , FBF, 100001, 1074359, 1118930).
我的create語句如下:
My create statement is as follows:
CREATE NONCLUSTERED INDEX idx_pick_ticket_popup_wmms
ON oe_pick_ticket (invoice_no, delete_flag, direct_shipment, auxiliary, oe_pick_ticket_type_cd, company_id, location_id, order_no)
我嘗試重建聚集/唯一/主鍵索引,但沒有任何改變.有誰知道我為什么會收到此錯誤以及如何解決它?
I have tried rebuilding the clustered/unique/primary key index and that didn't change anything. Does anyone know why I am getting this error and how to resolve it?
推薦答案
事實證明,我能夠自己解決這個問題.我在桌子上運行了一個 DBCC CHECKTABLE,結果不一致.之后,我使用 REBUILD_REPAIR 選項再次運行它并修復了主鍵不一致的問題.
It turns out that I was able to figure this out on my own. I ran a DBCC CHECKTABLE on the table and there was an inconsistency. After that I ran it again with the REBUILD_REPAIR option and it fixed the primary key inconsistency.
這篇關于創建非唯一索引時的唯一索引錯誤 - SQL Server的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!