Search

Tweak to duplicate key message by Louis Davidson

Active

6
1
Sign in
to vote
Type: Suggestion
ID: 679366
Opened: 7/13/2011 10:11:08 PM
Access Restriction: Public
0
Workaround(s)
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
Details (expand)

Product Language

English

Category

SQL Engine

Proposed Solution

Tweak the error message to make it clear that there may be > 1 duplicated value

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

Ideally you might have a bit more fill in the blanks and tell the number of violations if that information is available from the engine.

Primary Benefit

Improved User Interface

Other Benefits

Basically the error message would not imply that it was telling you more information than it is trying to.
File Attachments
0 attachments
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".
Sign in to post a workaround.