FIX: Error 515 with Concatenated NULLs in WHERE Clause and ORDER BY

Article translations Article translations
Article ID: 248442 - View products that this article applies to.
This article was previously published under Q248442
BUG #: 56173 (SQLBUG_70)
Expand all | Collapse all

SYMPTOMS

A query may return error 515, which is the following:
Cannot insert the value NULL into column '', table ''; column does not allow nulls. INSERT fails.
This can occur if all of the following conditions are true:
  • A string concatenation is done in the WHERE clause against a character column.
  • This column is used in an ORDER BY clause.
  • This column contains a NULL.
  • This column is not indexed.
  • The concat_null_yields_null option is not set for this connection or this database. This condition can be met by any one of the following:

    • Explicitly issuing the command set concat_null_yields_null off.
    • Using a client application that uses DB-Library or an ODBC driver older than version 3.70.0623.
    • Running the database in SQL Server 6.x compatibility mode.

WORKAROUND

To work around this problem, eliminate one of the preceding conditions that are known to cause it. For example, create an index on the column, or eliminate the NULL value(s).

Usually, the best work around is to index the column used in the ORDER BY clause. In addition to resolving this problem, in most cases, a query gains performance from indexing the columns used with the ORDER BY clause.

STATUS

Microsoft has confirmed this to be a problem in SQL Server 7.0. This problem has been corrected in U.S. Service Pack 2 for Microsoft SQL Server 7.0. For more information, click the following article number to view the article in the Microsoft Knowledge Base:
254561 INF: How to Obtain Service Pack 2 for Microsoft SQL Server 7.0 and Microsoft Data Engine (MSDE) 1.0
For more information, contact your primary support provider.

Properties

Article ID: 248442 - Last Review: March 14, 2006 - Revision: 2.1
APPLIES TO
  • Microsoft SQL Server 7.0 Standard Edition
Keywords: 
kbbug kbfix KB248442

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com