declare @t1 table (v1 varchar(20),v2 varchar(20),v3 varchar(20))
insert into @t1
select 'aaaa1','bbbb1','' union all
select 'aaaa2','','cccc2' union all
select '','bbbb3','cccc3' union all
select '','','' union all
select '','','cccc4'select v1,v2,v3,v4+v5+v6 v from (
select *,(case when v1 is null or v1='' then 'v1为空;' else '' end) v4
,(case when v2 is null or v2='' then 'v2为空;' else '' end) v5
,(case when v3 is null or v3='' then 'v3为空;' else '' end) v6
from @t1) b
insert into @t1
select 'aaaa1','bbbb1','' union all
select 'aaaa2','','cccc2' union all
select '','bbbb3','cccc3' union all
select '','','' union all
select '','','cccc4'select v1,v2,v3,v4+v5+v6 v from (
select *,(case when v1 is null or v1='' then 'v1为空;' else '' end) v4
,(case when v2 is null or v2='' then 'v2为空;' else '' end) v5
,(case when v3 is null or v3='' then 'v3为空;' else '' end) v6
from @t1) b
v1 v2 v3 v
-------------------- -------------------- -------------------- ---------------------
aaaa1 bbbb1 v3为空;
aaaa2 cccc2 v2为空;
bbbb3 cccc3 v1为空;
v1为空;v2为空;v3为空;
cccc4 v1为空;v2为空;(5 行受影响)
ISNULL(VAR_FLD,'空了')