FIX: Trigger Does Not Return Expected Duplicate Key Insert Error to Client (294311)



The information in this article applies to:

  • Microsoft SQL Server 2000 (all editions)

This article was previously published under Q294311
BUG #: 236053 (SHILOH_BUGS)

SYMPTOMS

When all of the following conditions are true, an expected error message may not be returned to the client for a duplicate key insert failure:
  • A distributed query is used.
  • The table has a trigger.
  • The trigger contains both a SELECT statement that returns a result set and a statement such as INSERT or UPDATE.
  • Within the trigger, the INSERT or UPDATE is performed on a table with a unique key and attempts to insert a duplicate record.
The UPDATE or INSERT statement within the trigger is terminated when it tries to insert a duplicate key row in the object, but it fails to report the expected duplicate key error to the client.

RESOLUTION

To resolve this problem, obtain the latest service pack for SQL Server 2000. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:

290211 INF: How to Obtain the Latest SQL Server 2000 Service Pack

WORKAROUND

When coding in a trigger, avoid using SELECT statements which return a result set.

STATUS

Microsoft has confirmed this to be a problem in SQL Server 2000. This problem was first corrected in SQL Server 2000 Service Pack 1.

Modification Type:MajorLast Reviewed:11/6/2003
Keywords:kbBug kbfix kbSQLServ2000sp1fix KB294311