CONCAT'ing NULL fields

前端 未结 11 847
小鲜肉
小鲜肉 2021-02-01 00:25

I have a table with three fields, FirstName, LastName and Email.

Here\'s some dummy data:

FirstName | LastName | Email
Adam        West       adam@west.c         


        
11条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-01 01:17

    Starting from MS SQL Server 2012 it was introduced CONCAT function and according to MSDN

    Null values are implicitly converted to an empty string. If all the arguments are null, an empty string of type varchar(1) is returned.

    so it's enough to use CONCAT without IsNull

    CONCAT(FirstName, LastName, Email)
    

提交回复
热议问题