BUG: Possible Handled AV w/ Sub-query Using NOT IN and '>'ID: Q150882
|
It is possible to experience a handled access violation (AV) when using an IN condition with a sub-query.
There are several conditions that must be present to get the AV:
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
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'
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 : kbprg SSrvProg kbbug6.00
Version : 6.0
Platform : WINDOWS
Issue type :
Last Reviewed: March 25, 1999