BUG: Possible Handled AV w/ Sub-query Using NOT IN and '>'

Last reviewed: May 2, 1997
Article ID: Q150882

The information in this article applies to:
  • Microsoft SQL Server, version 6.0
BUG#: 12628 (6.00)

SYMPTOMS

It is possible to experience a handled access violation (AV) when using an IN condition with a sub-query.

CAUSE

There are several conditions that must be present to get the AV:

  1. The select search criteria must contain an IN condition where the set of values is generated using a sub-query. The column referenced to the left of the IN condition and the column referred to in the sub-query both need to be defined as CHAR NOT NULL. An additional requirement is that the size of the column to the left of the IN condition must be greater than the column referred to in the sub-query.

  2. The second search criteria that the column referenced to the left of the IN condition must also be compared to a string value using either <, >, >=, or <= operators.

  3. There must be a non-unique index on the column referenced to the left of the IN condition.

The following is an example scenario:

create table test1 (a char(2) not null) create table test2 (b char(1) not null,

              c char(1) not null)
go
insert test1 values ('1') insert test2 values ('1','1') go create nonclustered index a on test1(a) go select a from test1 where a not in (select c from test2 where b = '1')and a <= '1' go

WORKAROUND

There are two possible means to workaround this problem. The first is to drop the current index and create either a unique clustered or non- clustered index. Or you can use the convert() function to step-up the column referenced in the sub-query to the same size as the column referenced on the left of the IN condition. An example of this 'step-up' would be to change the query to the following:

select a from test1 where a not in (select convert(char(2),c) from test2 where b = '1') and a <= '1'

STATUS

Microsoft has confirmed this to be a problem in Microsoft SQL Server version 6.0. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.


Additional query words: sql operator select sub-query
Keywords : kbbug6.00 kbprg SSrvProg
Version : 6.0
Platform : WINDOWS
Issue type : kberrmsg


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