Microsoft KB Archive/162366

= FIX: Using a WHERE IN Clause on a Selected UNION May Fail =

Article ID: 162366

Article Last Modified on 10/3/2003

-

APPLIES TO


 * Microsoft SQL Server 6.5 Service Pack 1

-



This article was previously published under Q162366



BUG #: 16400 (SQL6.5)



SYMPTOMS
SELECT statements consisting of a UNION and a WHERE IN clause may fail.

For example, the following statement

SELECT type, name FROM (SELECT * FROM master..sysobjects               UNION                SELECT * FROM pubs..sysobjects) as O      WHERE type IN ('S', 'U')

Produces (in part) the following results:

 type name -- U    authors P   byroyalty C   CK__authors__au_id__02DC7882 C   CK__authors__zip__04C4C0F4 C   CK__jobs__max_lvl__2719D8F8 C   CK__jobs__min_lvl__2625B4BF C   CK__publisher__pub_i__089551D8 C   CK_emp_id



WORKAROUND
Embed SELECT statements into the WHERE IN clause, as shown by the following:

SELECT type, name FROM (SELECT * FROM master..sysobjects        UNION         SELECT * FROM pubs..sysobjects) as O      WHERE type IN (SELECT 'S' UNION SELECT 'U')



STATUS
Microsoft has confirmed this to be a problem in Microsoft SQL Server version 6.5 Service Pack 1. 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.

Keywords: kbbug kbfix kbusage KB162366

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.