views:

47

answers:

1

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.

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

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?

+2  A: 

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.

Mark S.