中国开发网: 论坛: 程序员情感CBD: 贴子 391799
haitao
这个现象很容易重复的
建一个表:tbinfo
字段fid:自动递增;fdata:随便一个随机整数
插入3条记录:
fid fdata
1 1111
2 2222
3 3333
分别用asp和查询分析器 执行:sql
select a.*,isnull(b.fprevid,-1) fprevid,isnull(c.fnextid,-2) fnextid
from (SELECT * FROM tbInfo where fID=1 ) a
left 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 join (select top 1 1 as fid,fid as fnextid from tbinfo where fid>1
order by fnextid) c
on a.fid=c.fid

探查器得到asp提交的是:
declare @p1 int
set @p1=180150003
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 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 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

asp得不到记录
查询分析器则执行正常

--这个sql是用来取得一条记录,以及它的前后记录的fid的
在取第一条和最后一条时,才会这样asp和查询分析器不一致,取其它记录则都一致的
(上面的粗体的1,就是要取的记录的fid)
我的blog:http://szhaitao.blog.hexun.com & http://www.hoolee.com/user/haitao
--以上均为泛泛之谈--
不尽牛人滚滚来,无边硬伤纷纷现 人在江湖(出来的),哪能不挨刀(总归是要的)
网络对话,歧义纷生;你以为明白了对方的话,其实呢?

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

相关信息:


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