首页 新闻 会员 周边

sqlserver中需要在查询语句中把(null)输出为0 如何实现?

0
[已解决问题] 解决于 2009-09-15 20:23

??

失忆的双鱼的主页 失忆的双鱼 | 菜鸟二级 | 园豆:205
提问于:2009-09-15 17:42
< >
分享
最佳答案
0

--字符型
select isnull(mycol,'0') as newid from mytable
--整型
select isnull(mycol,0) as newid from mytable

邀月 | 高人七级 |园豆:25475 | 2009-09-15 17:49
good
失忆的双鱼 | 园豆:205 (菜鸟二级) | 2009-09-15 20:21
其他回答(3)
0

isnull(字段名称,0) as 字段名称

Mr雨 | 园豆:1199 (小虾三级) | 2009-09-15 17:47
0

columnName为字段名

case when columnName is null then 0 else columnName end

Kinglee | 园豆:3158 (老鸟四级) | 2009-09-15 17:49
0

create table MyTable(
   MyCol        int                  not null default 0 
)

建表的时候建列的默认值为0;

花落菩提 | 园豆:205 (菜鸟二级) | 2009-09-15 19:18
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册