Home Forums SQL Server 2005 T-SQL (SS2K5) cannot insert duplicate key row in object 'tablename' with unique index 'indexname' RE: cannot insert duplicate key row in object 'tablename' with unique index 'indexname'

  • Interesting - the primary key consists of [CostWorkOrder] plus another two columns, but [CostWorkOrder] is also defined separately as a unique key (the DML for this isn't in your script). That's a contradiction and suggests to me that one of these is a "band aid", perhaps for performance, but more likely to support the functionality of the application. IMHO you should set up a test environment and investigate what happens when you remove the constraint.

    “Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden