BUG: Incorrect SqlState on Constraint Violation

Last reviewed: May 1, 1997
Article ID: Q138540

The information in this article applies to:
  • Microsoft SQL Server, version 6.0
BUG#: 11704 (6.00)

SYMPTOMS

If the Microsoft SQL Server ODBC Driver encounters a constraint violation it raises a SqlState of 37000 (Syntax error or access violation) instead of 23000 (Constraint violation).

STATUS

Microsoft has confirmed this to be a problem in the Microsoft SQL Server ODBC Driver version 2.50.0121. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

This problem does not occur in version 2.65.0201.

MORE INFORMATION

If the driver encounters a SQL Server constraint violation, it correctly passes the error message back to the client:

   szSqlState = "37000"
   *pfNativeError =  2627
   szErrorMsg="[Microsoft][ODBC SQL Server Driver][SQL Server]
     Violation of PRIMARY KEY constraint 'PK__testkey__cola__38CE74DF':
     Attempt to insert duplicate key in object 'testkey'."

Instead of raising this with a SqlState of 37000, however, the driver should be raising a SqlState of 23000. This happens on both SQLExecDirect and SQLExecute.


Additional query words: sql6 odbc SQLExecDirect SQLExecute
Keywords : kbbug6.00 kbinterop SSrvProg
Version : 6.0 6.5
Platform : WINDOWS
Issue type : kberrmsg


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: May 1, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.