How to concatenate columns properly using T-SQL?

前端 未结 6 1959
时光说笑
时光说笑 2020-12-05 14:11

I have a address in more than one column in a table.

SELECT FirstName, LastName, StreetAddress, City, Country, PostalCode 
FROM Client

I a

6条回答
  •  青春惊慌失措
    2020-12-05 14:50

    Look at isnull

    You can also look at using COALESCE function, please look it up in BOL:

    Returns the first nonnull expression among its arguments.

    Finally another thing you could do is use a CASE function.

    SELECT Address1, CASE Address2 IS NOT NULL THEN "," + Address2 ELSE...
    

提交回复
热议问题