Replacing null with zero

前端 未结 3 723
情歌与酒
情歌与酒 2021-01-23 04:57

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.

selec         


        
相关标签:
3条回答
  • 2021-01-23 05:26

    Or you can use the COALESCE Function

    COALESCE(b.bId, 0) AS bId
    

    Performance: ISNULL vs. COALESCE

    0 讨论(0)
  • 2021-01-23 05:34

    As another alternative you could execute this sql at your ts table

    update ts
    set id = ''
    where id is null
    
    0 讨论(0)
  • 2021-01-23 05:37

    You can use the ISNULL function like so:

    ISNULL(b.bId, 0) bId
    
    0 讨论(0)
提交回复
热议问题