读书人

请问 自定义列 怎么替换Null

发布时间: 2012-01-30 21:15:58 作者: rapoo

请教 自定义列 如何替换Null ?

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


1NULL
0NULL
0周末
0NULL


请教如何将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 

读书人网 >SQL Server

热点推荐