Tweak to duplicate key message - by Louis Davidson

Status : 

  Won't Fix<br /><br />
		Due to several factors the product team decided to focus its efforts on other items.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.


7
1
Sign in
to vote
ID 679366 Comments
Status Closed Workarounds
Type Suggestion Repros 0
Opened 7/13/2011 10:11:08 PM
Access Restriction Public

Description

I realize it is a small thing, but the error message for a duplicated key value that was recently updated to include the key value implies that it is a single culprit. This was fixed based on https://connect.microsoft.com/SQLServer/feedback/details/470542/duplicate-key-values as far as I can tell. It is a great change with just a minor confusng bit.

So if I have a UNIQUE constraint on the following table on the otherColumn 

INSERT INTO test.testErrorMessage (testErrorMessageId,otherColumn)
VALUES (5,'Third'),(6,'Third'),(3,'Second'),(4,'Second')

You get the following:

Msg 2601, Level 14, State 1, Line 1
Cannot insert duplicate key row in object 'test.testErrorMessage' with unique index 'UXtestErrorMessage'. The duplicate key value is (Third).

But there was two duplicated key value. This could get frustrating to a novice user. This could be fixed since it is not production yet, but it would be stuck in eternity otherwise
Sign in to post a comment.
Posted by Microsoft on 7/18/2011 at 11:15 AM
Louis,

Thanks for the feedback.

Best regards,
Eric Hanson
Program Manager, SQL Server Query Processing
Posted by John Saunders on 7/14/2011 at 8:59 AM
I voted this important, and feel the wording should be changed. I will say however that this is really no different from any other statement where the first error terminates the statement (and the batch), but there might have been other errors found if the first error had not been found.

I recommend a wording change of some type because the duplicate key errors so frequently have a second error immediately following them. I wouldn't mind if the wording changed to say something like, "this is the first error; there may be more" or "if you fix this first error, then you may see the second".