FIX: A View With an Outer Join Can Cause An Access Violation

Last reviewed: May 2, 1997
Article ID: Q141542

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

SYMPTOMS

A SELECT against a view can result in the following error message:

   Msg 530, level 18, State 0
   Attempt to insert NULL value into column %d in work table (table id);
   column does not allow NULLS, UPDATE fails.

The connection will be terminated and the SQL Server error log will show a language exec error and an access violation.

CAUSE

For this bug to occur, the view needs to meet the following conditions:

  1. The SELECT clause needs to have a DISTINCT in it.
2. The query being performed by the SELECT must use an outer join. 3. A column in one of the tables must be a bit field.

When SQL Server forms the outer join work table, it mistakenly puts NULLS in the work table where the bit field is. By definition, a bit field must be either 0 or 1, and in the case of a NULL it should default to 0; however, in this case it does not.

WORKAROUND

You can circumvent the problem by avoiding any one of the three conditions that must be present to cause it.

STATUS

Microsoft has confirmed this to be a problem in Microsoft SQL Server version 6.0. This problem was corrected in Service Pack 2 for SQL Server version 6.0. For more information, contact your primary support provider.


Additional query words: sql6 views tsql
Keywords : kbbug6.00 kbfix6.00.sp2 kbusage SSrvGen SSrvTran_SQL
Version : 6.0
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 2, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.