創建非唯一索引時的唯一索引錯誤 - SQL Server

[英]Unique Index Error when creating non-unique index - SQL Server


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.

我試圖和SQL Server 2005中的表表的非唯一索引。當我嘗試創建它時,我收到以下錯誤。

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).

消息1505,級別16,狀態1,行1 CREATE UNIQUE INDEX語句終止,因為找到了對象名稱'dbo.oe_pick_ticket'和索引名稱'idx_pick_ticket_popup_wmms'的重復鍵。重復鍵值是(1093066,N,N,N,,FBF,100001,1074359,1118930)。

My create statement is as follows:

我的create語句如下:

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?

我已經嘗試重建clustered / unique / primary key索引,但沒有改變任何東西。有誰知道我為什么會收到此錯誤以及如何解決它?

1 个解决方案

#1


4  

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.

事實證明,我能夠自己解決這個問題。我在桌子上運行了一個DBCC CHECKTABLE並且存在不一致。之后,我使用REBUILD_REPAIR選項再次運行它,它修復了主鍵不一致。


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2010/08/03/729bd375f21f86876b400f109e977e19.html



 
粤ICP备14056181号  © 2014-2020 ITdaan.com