日期:2014-05-18 浏览次数:20601 次
create table tb ( col1 varchar(10), col2 varchar(10), col3 varchar(10), col4 varchar(10), col5 varchar(10) ) insert into tb select 'col',null,null,'col4','col5' GO declare @String varchar(max) SELECT @String=CONVERT(varchar(20),isnull(col1,'@'))+CONVERT(varchar(20),isnull(col2,'@'))+CONVERT(varchar(20),isnull(col3,'@')) +CONVERT(varchar(20),isnull(col4,'@'))+CONVERT(varchar(20),isnull(col5,'@')) from tb select datalength(@String)-datalength(REPLACE(@String,'@','')) as 'NULL值个数' GO DROP TABLE TB