How to merge three columns(nvarchar,null) into a single column (nvarchar) by keeping space between the each value if value is not null ?

I have three columns like FirstName, MiddleName, LastName I want merge them all into a single column like FullName by giving space between the Fistname and Middle, Middle and LastName if the values are not null.

1 answer

  • answered 2018-10-09 16:43 Serkan Arslan

    You can try this

    SELECT ISNULL(FirstName,'') + ' ' + ISNULL(MiddleName,'')  + ' ' + ISNULL(LastName,'') AS FullName
    FROM [Table]