Skip to content

Instantly share code, notes, and snippets.

@AlexArchive
Created July 29, 2013 10:35
Show Gist options
  • Save AlexArchive/6103479 to your computer and use it in GitHub Desktop.
Save AlexArchive/6103479 to your computer and use it in GitHub Desktop.
Combines a table's FirstName and LastName attributs to form a single aliased Attribute while handling NULL in various ways.
SELECT empid, firstname + N' ' + lastname AS full_name
FROM HR.Employees
SELECT
empid,
--country + N', ' + region + N', ' + city AS location
--country + COALESCE(N',' + region, N'') + N',' + city AS location
CONCAT(country + N', ', region + N', ', + city ) AS location
FROM HR.Employees
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment