FIX: Coalesce with Subquery May Generate an Access Violation

Article translations Article translations
Article ID: 298803 - View products that this article applies to.
This article was previously published under Q298803
BUG #: 352326 (SHILOH_BUGS)
Expand all | Collapse all

SYMPTOMS

When you run a coalesce query that contains a subquery the following error message may occur:
ODBC: Msg 0, Level 19, State 1
SqlDumpExceptionHandler: Process 52 generated fatal exception c0000005 EXCEPTION_ACCESS_VIOLATION. SQL Server is terminating this process.

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

Change the query so that it uses CASE WHEN or IF ELSE statements instead. For example:
  • CASE
       WHEN (expression1 IS NOT NULL) THEN expression1
       ...
       WHEN (expressionN IS NOT NULL) THEN expressionN
       ELSE NULL
    						
    -or-

  • IF (expression1 IS NOT NULL) expression1
       ELSE 
       IF (expression2 IS NOT NULL) expression2
       ...
       ELSE NULL
    						

STATUS

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

MORE INFORMATION

To reproduce the problem, use this code:
USE northwind
GO
SELECT COALESCE 
    ((SELECT COUNT(p.productid)
      FROM  Products p 
      INNER JOIN Suppliers s 
      ON p.supplierid = s.supplierid 
      WHERE city = 'London' ),0)
GO
				

Properties

Article ID: 298803 - Last Review: November 5, 2003 - Revision: 3.2
APPLIES TO
  • Microsoft SQL Server 2000 Standard Edition
Keywords: 
kbbug kbfix kbsqlserv2000sp1fix KB298803

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