declare @table table (colname varchar(1)) insert into @table select 'a' union all select 'b' union all select '' union all select 'd'select colname=case when colname='' then '你要显示的值' else colname end from @table /* colname ------------ a b 你要显示的值 d */
select isnull(a,b) 字段1 from 表
但如果是 '' 空字符呢?
declare @table table (colname varchar(1))
insert into @table
select 'a' union all
select 'b' union all
select '' union all
select 'd'select colname=case when colname='' then '你要显示的值' else colname
end
from @table
/*
colname
------------
a
b
你要显示的值
d
*/