Wednesday, March 21, 2012

Incorrect Results -- is a hotfix available?

I have a query that is returning incorrect results. It is reproducible on
SQL 2000 SP4 (version 2040) and SP3a (version 760). It tried on 6 different
machines, all with different operating systems/hardware/etc.
Is there a hotfix available?
The following should not return any rows, but 1 row is returned:
declare @.fg table (FK1 int, FK2 int, FK3 int, FK4 int)
insert into @.fg
select 4, 4, 798, 13734
declare @.dg table (ID int, C1 varchar(20))
insert into @.dg
select 4, 'AAA'
declare @.drg table (C1 varchar(20))
insert into @.drg
select 'AAA'
declare @.fgt table (ID int, C1 char(1))
insert into @.fgt
select 4, 'F'
declare @.dwf table (ID int, FK1 int, FK2 int)
insert into @.dwf
select 798, 4, 46
declare @.f table (ID int)
insert into @.f
select 46
declare @.dwc table (ID int)
insert into @.dwc
select 4
select ID = 1
from @.fg fg
inner join @.dg dg on dg.ID = fg.FK1
inner join @.drg drg on drg.C1 = isnull(dg.C1, '')
inner join @.fgt fgt on fgt.ID = fg.FK2
inner join @.dwf dwf on dwf.ID = fg.FK3
inner join @.dwc dwc on dwc.ID = dwf.FK1
inner join @.f f on f.id = dwf.FK2
left join (select ID = 1, FK1 = 1234) ag on ag.ID = fg.FK4
left join (select ID = 1, C1 = '') dt on dt.ID = ag.FK1
inner join (select C1 = 1) c1 on c1.C1 = 1
inner join (select C2 = 1) c2 on c2.C2 = 1
where
isnull(dt.C1, '') = 'XYZ'This produces 0 rows on SQL Server 2005 (build 1399) and on SQL Server 2000
(build 2151 and build 2162).
You might want to see which (if any) specific hotfix references this issue.
See http://www.aspfaq.com/sql2000builds.asp
#2162 was available publicly until Friday or so, it was pulled due to a
couple of pretty serious issues. I noticed at least one of those issues on
#2151 also, which I am currently running, so please only try to obtain the
absolute highest build number you need, especially if you use a failover
cluster and/or rely on BULK INSERT.
Based on a quick scan, looks like the build # you need is 2145, but I did
not read the KB articles in full.
A
"davedave" <davedave@.discussions.microsoft.com> wrote in message
news:54BCCA28-6F9C-484D-976C-F357D2BF7D07@.microsoft.com...
>I have a query that is returning incorrect results. It is reproducible on
> SQL 2000 SP4 (version 2040) and SP3a (version 760). It tried on 6
> different
> machines, all with different operating systems/hardware/etc.
> Is there a hotfix available?
> The following should not return any rows, but 1 row is returned:
> declare @.fg table (FK1 int, FK2 int, FK3 int, FK4 int)
> insert into @.fg
> select 4, 4, 798, 13734
> declare @.dg table (ID int, C1 varchar(20))
> insert into @.dg
> select 4, 'AAA'
> declare @.drg table (C1 varchar(20))
> insert into @.drg
> select 'AAA'
> declare @.fgt table (ID int, C1 char(1))
> insert into @.fgt
> select 4, 'F'
> declare @.dwf table (ID int, FK1 int, FK2 int)
> insert into @.dwf
> select 798, 4, 46
> declare @.f table (ID int)
> insert into @.f
> select 46
> declare @.dwc table (ID int)
> insert into @.dwc
> select 4
> select ID = 1
> from @.fg fg
> inner join @.dg dg on dg.ID = fg.FK1
> inner join @.drg drg on drg.C1 = isnull(dg.C1, '')
> inner join @.fgt fgt on fgt.ID = fg.FK2
> inner join @.dwf dwf on dwf.ID = fg.FK3
> inner join @.dwc dwc on dwc.ID = dwf.FK1
> inner join @.f f on f.id = dwf.FK2
> left join (select ID = 1, FK1 = 1234) ag on ag.ID = fg.FK4
> left join (select ID = 1, C1 = '') dt on dt.ID = ag.FK1
> inner join (select C1 = 1) c1 on c1.C1 = 1
> inner join (select C2 = 1) c2 on c2.C2 = 1
> where
> isnull(dt.C1, '') = 'XYZ'
>

No comments:

Post a Comment