Programmers learn & share
+1 vote
47 views

Problem :

I am facing bellow error
the create unique index statement terminated because a duplicate key was found for the object name
by (6.9k points)   | 47 views

1 Answer

0 votes

Solution :

The problem is not that index already exists but there are duplicate values of the TopicShortName field in the table itself. Such duplicates prevent the creation of a UNIQUE index.

So you should run a query to confirm that you have a duplicate:

SELECT
    TopicShortName,
    COUNT(*)
FROM
    DimMeasureTopic
GROUP BY
    TopicShortName
HAVING
    COUNT(*) > 1

Presumably in the other database the data are different, and the duplicates are not present.

This will certainly solve your problem.

Further Readings :

https://www.ibm.com/support/pages/refresh-fails-create-unique-index-statement-terminated-because-duplicate-key-was-found-error-while-replicating-sql-server-target

by (36.1k points)  
2,187 questions
2,514 answers
59 comments
241 users