create table #cols (colname varchar(255), nullCount int)insert into #cols (colname)select name from syscolumns where id = object_id('tblTest')declare @c varchar(255)declare curCols cursor for select colname from #colsopen curColsfetch next from curCols into @cwhile @@fetch_status = 0 begin exec ('update #cols set nullCount = (select count(*) from tblTest where ' + @c + ' is not null) where colname = ''' + @c + '''') fetch next from curCols into @cendclose curColsdeallocate curColsdeclare @rv table (cols_expect_those_with_null_only varchar(255))insert into @rv (cols_expect_those_with_null_only)select colname from #colswhere nullCount > 0drop table #colsselect * from @rv
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)