没有登录
中国开发网: 论坛: 程序员情感CBD: 贴子 392688
haitao
关于asp+ado+leftjoin的问题,刚才在2台机器试了
xp iis asp+sql2k开发版:和茶壶一样,一切正常
win2k3 iis asp+sql2k标准版:一切正常

我的win2k3 iis asp+sql2k5企业版:就是首尾2条记录不正常

xp iis asp+sql2k5企业版:也是首尾2条记录不正常


好像焦点集中到了sql2k5!!!
--sql2k5直接执行left join肯定是没问题的
就是asp+ado连的时候,一个sql被转为多个命令,而且命令的条数居然是不一定的!!
【没有结果的:抓自sql2k5
declare @p1 int
set @p1=180150023
declare @p3 int
set @p3=1
declare @p4 int
set @p4=1
declare @p5 int
set @p5=1
exec sp_cursoropen @p1 output,N' select a.*,isnull(b.fprevid,-1) fprevid,isnull(c.fnextid,-2) fnextid from (SELECT * FROM tbInfo where fID=1 ) a left OUTER join
(select top 1 1 as fid,fid as fprevid from tbinfo where fid<1 order by fprevid desc) b on a.fid=b.fid left OUTER join (select top 1 1 as fid,fid as fnextid from
tbinfo where fid>1 order by fnextid) c on a.fid=c.fid ',@p3 output,@p4 output,@p5 output
select @p1, @p3, @p4, @p5


exec sp_cursorfetch 180150023,16,1,64


exec sp_cursorfetch 180150023,16,1,1

exec sp_cursorclose 180150023

【有结果的:抓自sql2k5
declare @p1 int
set @p1=180150013
declare @p3 int
set @p3=1
declare @p4 int
set @p4=1
declare @p5 int
set @p5=1
exec sp_cursoropen @p1 output,N' select a.*,isnull(b.fprevid,-1) fprevid,isnull(c.fnextid,-2) fnextid from (SELECT * FROM tbInfo where fID=2 ) a left OUTER join
(select top 1 2 as fid,fid as fprevid from tbinfo where fid<2 order by fprevid desc) b on a.fid=b.fid left OUTER join (select top 1 2 as fid,fid as fnextid from
tbinfo where fid>2 order by fnextid) c on a.fid=c.fid ',@p3 output,@p4 output,@p5 output
select @p1, @p3, @p4, @p5

exec sp_cursorfetch 180150013,16,1,64

exec sp_cursorfetch 180150013,16,2,64

exec sp_cursorfetch 180150013,16,1,1

exec sp_cursorclose 180150013

【正常的:抓自sql2k
declare @P1 int
set @P1=0
declare @P2 int
set @P2=98305
declare @P3 int
set @P3=98305
declare @P4 int
set @P4=0
exec sp_cursoropen @P1 output, N' select a.*,isnull(b.fprevid,-1) fprevid,isnull(c.fnextid,-2) fnextid from (SELECT * FROM tbInfo where fID=4 ) a
left OUTER join (select top 1 4 as fid,fid as fprevid from tbinfo where fid<4 order by fprevid desc) b on a.fid=b.fid left OUTER join (select top
1 4 as fid,fid as fnextid from tbinfo where fid>4 order by fnextid) c on a.fid=c.fid ', @P2 output, @P3 output, @P4 output
select @P1, @P2, @P3, @P4

declare @P1 int
set @P1=180150001
declare @P2 int
set @P2=8
declare @P3 int
set @P3=1
declare @P4 int
set @P4=1
exec sp_cursoropen @P1 output, N' select a.*,isnull(b.fprevid,-1) fprevid,isnull(c.fnextid,-2) fnextid from (SELECT * FROM tbInfo where fID=4 ) a
left OUTER join (select top 1 4 as fid,fid as fprevid from tbinfo where fid<4 order by fprevid desc) b on a.fid=b.fid left OUTER join (select top
1 4 as fid,fid as fnextid from tbinfo where fid>4 order by fnextid) c on a.fid=c.fid ', @P2 output, @P3 output, @P4 output
select @P1, @P2, @P3, @P4

exec sp_cursorfetch 180150001, 16, 1, 2

exec sp_cursorfetch 180150001, 16, 2, 2

exec sp_cursorfetch 180150001, 16, 1, 1

exec sp_cursorclose 180150001
我的blog:http://szhaitao.blog.hexun.com & http://www.hoolee.com/user/haitao
--以上均为泛泛之谈--
不尽牛人滚滚来,无边硬伤纷纷现 人在江湖(出来的),哪能不挨刀(总归是要的)
网络对话,歧义纷生;你以为明白了对方的话,其实呢?

您所在的IP暂时不能使用低版本的QQ,请到:http://im.qq.com/下载安装最新版的QQ,感谢您对QQ的支持和使用

相关信息:


欢迎光临本社区,您还没有登录,不能发贴子。请在 这里登录