T SQL Conditional String Concatenation

后端 未结 5 816
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-05 16:55

Have a 5 columns of address data. I need to concatenate these fields into a single address with spaces in between the values if they exist. If the column has a null value

5条回答
  •  别那么骄傲
    2021-01-05 17:22

    Nested isnulls could do what you need. Something like:

    SELECT
         ISNULL(streetnumber + ' ', '')
           + ISNULL(streetext + ' ', '')
           etc
    

    relying on the fact that NULL + ' ' = NULL.

提交回复
热议问题