你的效率太低,改语句先吧
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 '
)
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 '
)
解决方案 »
- 关于一个create database的基础题
- sql server 如何为xml类型节点增加一个属性?
- 求SELECT语句,如何同时显示两个表里的所有列?
- 关于存储过程中取数据做参数的问题
- 游标有什么作用?
- 请大家谈一下大型信息管理系统的数据库解决方案(需通过Internet传输数据),来者有分!
- 在SQLAgent建立作业执行存储过程失败, 而在查询分析器执行则成功,求救!
- 连装了两次sqlserver都不行 高手帮忙
- 請教高手,怎麼樣不編程只使用諸如DTS之類工具,實現把2張表合成一張表
- sql如何清空执行完提示的信息?比如(print 1;输出“1” 但不显示1,直接空白一片)
- SQL SERVER数据库如何连接远程ORACLE数据库?
- SQL 库存计算问题
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'
)
sfsj between '2007-11-10 04:26:39 ' and '2007-11-14 10:11:13 ' ---------
这两个差不多,效率上应该没有什么差别
你可以把它们分成两句,看看执行计划
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 '
) 如果,先查询注释的,然后再查询没注释的,结果是怎样呢?