FIX: Access Violation from Query with Multiple UNIONs Within Parenthesis (308761)



The information in this article applies to:

  • Microsoft SQL Server 2000 (all editions)

This article was previously published under Q308761
BUG #: 355044 (SHILOH_BUGS)

SYMPTOMS

A query that contains multiple UNIONs and at least one UNION inside parenthesis may result in an Access Violation during the query compilation phase. The query works if you eliminate the parenthesis.

RESOLUTION

To resolve this problem, obtain the latest service pack for Microsoft 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

To work around this problem, remove the parenthesis outside the UNION clause.

STATUS

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

MORE INFORMATION

To reproduce the behavior, run the following code:
USE pubs
GO

CREATE TABLE Tbl_a ( col1_a varchar(100) ) 
CREATE TABLE Tbl_b ( col1_b varchar(100) ) 
CREATE TABLE Tbl_c ( col1_c varchar(100) ) 
GO

SELECT    col1_a 
FROM      Tbl_a  
UNION
(SELECT   col1_b 
FROM      Tbl_c, Tbl_b 
UNION
SELECT    col1_b 
FROM      Tbl_b  )
GO
				
The query fails with an Access Violation. Here is the short stack dump:
Short Stack Dump
00642184 Module(sqlservr+00242184) (norm_setop+000001D1)
005D3A0B Module(sqlservr+001D3A0B) (CProchdr::NormQuery+000000A7)
00443DB2 Module(sqlservr+00043DB2) (CProchdr::FCompile+000002EF)
00412F15 Module(sqlservr+00012F15) (CSQLSource::FTransform+0000034C)
00448D11 Module(sqlservr+00048D11) (CSQLStrings::FTransform+000001A1)
00412851 Module(sqlservr+00012851) (CSQLSource::Execute+0000015B)
00448916 Module(sqlservr+00048916) (language_exec+000003E1)
00411D4C Module(sqlservr+00011D4C) (process_commands+000000E0)
41073379 Module(UMS+00003379) (ProcessWorkRequests+0000024A)
41073071 Module(UMS+00003071) (ThreadStartRoutine+000000BD)
7800BEA1 Module(MSVCRT+0000BEA1) (beginthread+000000CE)
77E837CD Module(KERNEL32+000037CD) (TlsSetValue+000000F0)
				

Modification Type:MajorLast Reviewed:10/16/2003
Keywords:kbbug kbfix KB308761