FIX: Inserting NULL into NOT NULL Column May Cause AV

Last reviewed: April 30, 1997
Article ID: Q122574

The information in this article applies to:
  • Microsoft SQL Server, version 4.21a
BUG# NT: 904 (4.21a)

SYMPTOMS

When you try to insert a NULL into a NOT NULL column inside a trigger, an access violation may occur under certain situations. For example, consider the following INSERT statement to be executed inside a trigger:

   insert mytable select (select NULL)

The first time this trigger is fired, it causes error 515 (as expected):

   Attempt to insert the value NULL into column '%.*s', table '%.*s';
   column does not allow NULLS. Update fails

If the trigger is fired again, an access violation may occur.

NOTE: This problem occurs only if you are trying to insert NULLs into a column that does not allow NULLs. A trigger should not be designed to perform an invalid operation.

WORKAROUND

There are two ways to avoid this problem:

  • Redesign the trigger so that it does not insert NULLs into a column that does not allow NULLs.
  • Remove the extra SELECT statement. For example:

          insert mytable select (NULL)
    

STATUS

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


Additional query words: sql6 Windows NT
Keywords : kbbug4.21a kbfix6.00 kbother kbprg SSrvProg SSrvTran_SQL
Version : 4.21 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: April 30, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.