你的效率太低,改语句先吧
select   czbz,jsje,jsmc   from   hjsfjsb   where   
                hjsfjsb.czbz=1   and   exists (
select 1 from  hjsfb   where  jzh=hjsfjsb.jzh and jsxh=a.jsxh and
 isnull(hjsfb.gzh, '')=''   and 
sfsj   between     '2007-11-10 04:26:39 '   and   '2007-11-10 04:26:40 '   

解决方案 »

  1.   

    写错了,整理下
    select czbz,jsje,jsmc       
    from hjsfjsb a
    where czbz=1
    and exists   ( 
      select 1 from hjsfb
      where jzh=a.jzh
      and jsxh=a.jsxh
      and isnull(hjsfb.gzh,'')= ''
      and sfsj between '2007-11-10 04:26:39' and '2007-11-10 04:26:40'
      )   
      

  2.   

            --     sfsj   between     '2007-11-10   04:26:40 '   and   '2007-11-14   10:11:13 '   
    sfsj   between     '2007-11-10   04:26:39 '   and   '2007-11-14   10:11:13 '   ---------
    这两个差不多,效率上应该没有什么差别
    你可以把它们分成两句,看看执行计划
      

  3.   

    select   czbz,jsje,jsmc   from   hjsfjsb   where   
                    hjsfjsb.czbz=1   and   convert(nvarchar(20),jzh)+convert(nvarchar(10),jsxh)   in   

                    select   convert(nvarchar(20),jzh)+convert(nvarchar(10),jsxh)   as   aa   from   hjsfb   where   1=1   and   len(isnull(hjsfb.gzh, ' '))=0   and 
            --     sfsj   between     '2007-11-10   04:26:40 '   and   '2007-11-14   10:11:13 '   
    sfsj   between     '2007-11-10   04:26:39 '   and   '2007-11-14   10:11:13 '   
    ) 如果,先查询注释的,然后再查询没注释的,结果是怎样呢?