寻求高效的代码,如果选出一个字符型字段中为空串,或为空格,或为null的所有记录,一句代码
----------------------
我能想到的以下几句,不知哪句好,有没有更好的。
select * from 表名 where isnull(字段名,'')=''
select * from 表名 where len(isnull(字段名,''))=0

解决方案 »

  1.   

    select * from tb where col is null or len(rtrim(ltrim(col))) = 0
      

  2.   

    select * from tb where  isnull(ltrim(rtrim(col)),1)=1
      

  3.   

    select * from 表名 where 字段名 is null--不用使用转换
      

  4.   

    select * from 表名 where 字段名 is null--不用使用转换
    ---------
    不是只选null的记录,还要同时选出为空串的,为全角空格的,为半角空格的
      

  5.   

    如果下面是一个全角空格的话,试试输出什么
    print '|'+rtrim(' ')+'|'
      

  6.   

    select *
    from table
    where field in ('',' ',null)