同意libin_ftsafe(子陌红尘) ( ) 
在列上做了函数处理之后,将无法引用到列上创建的索引。
---------------------------------------------------
何不转换一下?

解决方案 »

  1.   

    select  *  from table1 where A between '2005-12-01' and '2005-12-01 23:59:59'
      

  2.   

    在列上做了函数处理之后,将无法引用到列上创建的索引。
    ---------------------------------------------------
    那有没有什么解决方法呢?这个问题其实挺严重的,在很多情况下都要用到datediff作为过滤条件的,不会就只能转换形式成:
    select  *  from table1 where A between '2005-12-01' and '2005-12-01 23:59:59'
      

  3.   

    请 libin_ftsafe(子陌红尘) 给我个解决方法,好吗?
      

  4.   

    这个方法是快,但有另一个问题,请看:select  *  from table1 where A between '2005-12-01' and '2005-12-01 23:59:59'这样就快但这样就慢
    declare @d_date char(10)
    set @d_date='2005-12-01'
    select  *  from table1 where A between  @d_date and @d_date+' 23:59:59'而实际上,我这个肯定要用变量的呀。请问这是为什么呢
      

  5.   

    不会呀declare @d_date datetime --不要设为字符串
    set @d_date='2005-12-01'
    select  *  from table1 where A between  @d_date and @d_date+'23:59:59'
      

  6.   

    不要对查询的条件字段进行运算和使用函数http://www.blog.com.cn/user25/lijunyi/
      

  7.   

    另外,还有个新发现A 字段为datetime, 降序索引select top 1  *  from table1
    where A < '2005-12-30'
    这样,十分快但
    select top 1  *  from table1
    where A > '2005-12-30'
    十分快,就是大于与小于的区别,为什么差别这么大。什么原理?
      

  8.   

    select  *  from table1
    where A > '2005-12-30'
    影响的行大于
    select  *  from table1
    where A < '2005-12-30'??????????????
      

  9.   

    呵呵,刚好相反,<的反而是多行的,>则是少行反回的.另:我没有对此日期型字段做聚集索引的