Microsoft KB Archive/138540

{|
 * width="100%"|

BUG: Incorrect SqlState on Constraint Violation

 * }

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 : kbinterop

Issue type : kbbug

Technology : kbSQLServSearch kbAudDeveloper kbSQLServ600