[阅读: 813] 2006-09-06 07:42:24
[2416] 15:33:21.267|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
]
事件探查器得到的是:
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
把它放在 查询分析器 里执行,的确是没有记录!
哦。。。好像a的where里fid='1',asp就不行,fid=1就行--fid本来是整数,mssql好像都会自动转换的
而查询分析器,就都行