2

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
  • Are you 100% sure that index doesn't already exist? Have you tried dropping it to see if it throws an error? It sounds like that index name is already present on that table. Commented Aug 3, 2010 at 16:57
  • Odd that the error message talks about a UNIQUE index but I don't see the UNIQUE keyword in the statement you've provided. There seems to be a disconnect there. Commented Aug 3, 2010 at 17:56

1 Answer 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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.