用零替换 null [英] Replacing null with zero

查看:42
本文介绍了用零替换 null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 SQL Server 中有以下选择命令.我正在尝试更改它,因此如果 b.bId 为空,我想为其分配 0 值.所以它在字段中显示 0.

Hi I have following select command in SQL Server. I am trying to change it so if b.bId is null i want to assign it 0 value. So it displays 0 in the field.

select top 1
    a.sId
   ,b.bId  
    from tlocal a
    left outer join ts b on (b.id=a.mainId)
    where 
    a.id=@xId; 

请告诉我如何修改.谢谢

Please let me know how to modify. Thanks

推荐答案

你可以像这样使用 ISNULL 函数:

You can use the ISNULL function like so:

ISNULL(b.bId, 0) bId

这篇关于用零替换 null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆