表里有100列,其中有很多列值都为null,我想查询所有不是null的列

解决方案 »

  1.   

    where col1+col2.......+col100 is not null
      

  2.   

    怎么会有这种需求,肯定不同数据类型
    那就 col1  is not null
    adn col2 is not null
    and.................
    adn col200 is not null
      

  3.   

    where col1  is not null
    and col2 is not null  ......
      

  4.   

      and 写错了!!
      

  5.   

    数据库里面拼sql吧。100列列名全写出来....
      

  6.   

    DECLARE @colname nvarchar(4000)
    SELECT @colname=ISNULL(@colname,'')+name++' IS NOT NULL AND ' FROM syscolumns WHERE id=OBJECT_ID('tb')
    DECLARE @sql nvarchar(4000)
    SET @sql='SELECT * FROM tb WHERE '+@colname+'1=1'
    EXEC(@sql)