FIX: Err 511: Stored Proc w/ANSI_NULL_DFLT_ON Creates Temp Tbl

Last reviewed: April 30, 1997
Article ID: Q167606
The information in this article applies to:
  • Microsoft SQL Server, versions 6.0 and 6.5
BUG #: 16814 (NT: 6.5)

SYMPTOMS

A stored procedure that creates a temporary table without explicitly specifying column nullability and INSERTS into that table will fail with an error 511 if the procedure was created with ANSI_NULL_DFLT_ON set on, and is run with ANSI_NULL_DFLT_ON set off. This problem occurs if you do all of the following:

  1. Run the procedure.

  2. Perform sp_recompile on an underlying permanent table referenced in the procedure.

  3. Run the procedure again.

The error 511 occurs on the second execution after the recompile. All ODBC connections set ANSI_DEFAULTS on, which in turn sets ANSI_NULL_DFLT_ON on. Therefore, any procedure created over ODBC is susceptible to this problem.

WORKAROUND

To work around this problem, do either of the following:

  • Explicitly specify columns as NULL, or NOT NULL during the table definition in the stored procedure.

    -or-

  • Specify the ANSI_NULL_DFLT_ON setting for clients before running the stored procedure.

STATUS

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

MORE INFORMATION

A similar problem occurs if the tables created in the procedure are permanent tables. For more information, see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q167605
   TITLE     : BUG: Err 511: Stored Proc w/ANSI_NULL_DFLT_ON Creates
               Perm Tbl
 

	
	


Keywords : kbbug6.00 kbbug6.50 kbfix6.50.sp2 kbusage SSrvStProc
Version : 6.0 6.5
Platform : WINDOWS
Issue type : kbbug
Resolution Type : kbfix


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.