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

解决方案 »

  1.   

    (5 行受影响)
    v1                   v2                   v3                   v
    -------------------- -------------------- -------------------- ---------------------
    aaaa1                bbbb1                                     v3为空;
    aaaa2                                     cccc2                v2为空;
                         bbbb3                cccc3                v1为空;
                                                                   v1为空;v2为空;v3为空;
                                              cccc4                v1为空;v2为空;(5 行受影响)
      

  2.   

    不难的!就是一个case when
      

  3.   

    如果v1有值得话。再select table3.v1 from table3,table2 where  table2.v1=table3.v1  如果table3.v1也为空的话,那么table2.v1也认为是空。这个怎么嵌套进去啊?呵呵
      

  4.   

    用 
    ISNULL(VAR_FLD,'空了')
      

  5.   

    為什么要v4+v5+v6   后面的b是什么意思?