select c.accnt_no,c.accnt_chi as accntname,c.big_no,c.drcr,case left(c.big_no,1) when 'a' then 0 when 'b' then 0 when 'c' then 0 else 1 end as type from voucher_detail a,voucher b,accnt c where c.grade>=9 and a.company=b.company and b.company=c.company and a.company='SM' and a.accnt_no=c.accnt_no and ((isnull(c.AccGroupID,'')='0002' or isnull(b.AccGroupID,'')='') or a.deptno in('060400','060405','06040500','06040501','06040502','06040503','06040504','06040505','06040506','06040507','06040508','06040509','06040510','06040511')) and a.accnt_no <>'3131' and left(a.accnt_no,10)>='1911001001' and left(a.accnt_no,10) <='1911001012' and a.obs <>1 and c.isdetail=1 group by c.accnt_no,c.accnt_chi,c.big_no,c.drcr order by type,c.accnt_no
select top 20 (stkadj.company) as company,(stkadj.docno) as docno,(stkadj.trndate) as trndate,(stkadj.ifflow) as ifflow, (stkadj.ifpost) as ifpost,(customer.abrname) as abrname from (stkadj inner join customer on stkadj.company=customer.company and stkadj.cusno=customer.cusno ) inner join blcpending_doc p on p.company=stkadj.company and p.docno=stkadj.docno and p.status=1 and p.staffno='004834' where stkadj.company in ('AB') and stkadj.ifvalid=1 and stkadj.trncode='4091' and (stkadj.acntperiod='200808') order by stkadj.docno
上面的语句中注释掉stkadj.company=('AB')或注释掉 and (stkadj.acntperiod='200808')或注释掉 top 20 执行正常,很快就回返回结果! 或者只将p.staffno='004834'改为p.staffno='admin'执行正常,很快就回返回结果! 这一SQL语句在别的服务器上也是SP3就没有问题!区别就是现在的服务器装的是Server 2003 SP2另外一台装的是SP1,应该与这个无关吧!