当前位置: 代码迷 >> Sql Server >> 请问 自定义列 怎么替换Null
  详细解决方案

请问 自定义列 怎么替换Null

热度:93   发布时间:2016-04-27 18:07:54.0
请教 自定义列 如何替换Null ?

select 
*,(select type from tableB where tableA.id = tableB.id)
from tableA


1 NULL
0 NULL
0 周末
0 NULL


请教如何将Null批量成别的字符串呢?



select 
*,(select case when type is Null then '空字符串' else then type end from tableB where tableA.id = tableB.id)
from tableA

这样也不行,因为内查询没有查询到数据,
将case 放到最外边,总是报错.

------解决方案--------------------
ISNULL(col,'aa')
------解决方案--------------------
SQL code
select  *,(select isnull(type,'你想要的字符串') from tableB where tableA.id = tableB.id)from tableA
------解决方案--------------------
SQL code
select  *,(select isnull(type,'别的字符') from tableB where tableA.id = tableB.id)from tableA
  相关解决方案