declare @table_name as varchar(max)
set @table_name = 'C0t01'
declare @column_Value varchar(200)
declare aaaaa cursor for
select sys.columns.name
from sys.columns, sys.tables, sys.types where sys.columns.object_id = sys.tables.object_id and sys.columns.system_type_id=sys.types.system_type_id and sys.tables.name=@table_name order by sys.columns.column_id
open aaaaa
fetch next from aaaaa into @column_Value
while @@fetch_status=0
begin
declare @strsql varchar(200)
set @strsql='select * from '+@table_name+' where '+@column_Value+' is null'
execute(@strsql)
if @@rowcount>0
begin
print '列'+@column_Value+'有空值'
end
ELSE
fetch next from aaaaa into @column_Value
end
close aaaaa
deallocate aaaaa