怎么会有这种需求,肯定不同数据类型 那就 col1 is not null adn col2 is not null and................. adn col200 is not null
where col1 is not null and col2 is not null ......
and 写错了!!
数据库里面拼sql吧。100列列名全写出来....
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)
那就 col1 is not null
adn col2 is not null
and.................
adn col200 is not null
and col2 is not null ......
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)