BUG: SELECT w/ Correlated Subquery Can Result in Error 403

Last reviewed: April 8, 1997
Article ID: Q153692

The information in this article applies to:
  • Microsoft SQL Server, version 6.5

SYMPTOMS

A SELECT statement that includes a correlated subquery in the select list, where the subquery performs an aggregate operation on a DISTINCT column and the outermost SELECT statement has a restriction clause of a structure more complex than <column> <relational operator> <constant>, may result in the following error:

   Msg 403, Level 16, State 1
   Invalid operator for datatype op: UNKNOWN TOKEN type: <type>

MORE INFORMATION

This problem is specific to the structure of the SELECT statement. If any part of the statement is altered the error will not be raised.

For example, if the following tables are created:

   CREATE TABLE t1 (c1 int, c2 int)
   CREATE TABLE t2 (c1 int, c2 int)

The following select statement will demonstrate the problem:

   SELECT t2.c1, (SELECT COUNT(DISTINCT t1.c1) FROM t1 WHERE t1.c2 =
   t2.c2) FROM t2 WHERE t2.c1<>2

If the final restriction clause is changed to 'column > constant', thus:

   SELECT t2.c1, (SELECT COUNT(DISTINCT t1.c1) FROM t1 WHERE t1.c2 =
   t2.c2) FROM t2 WHERE t2.c1>2

the statement will be executed as expected. If the DISTINCT clause is removed from the subquery again, the query will execute as expected.

STATUS

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


Additional query words:
Version : 6.5
Platform : WINDOWS


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 8, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.