This SQL seems complex, is there an easier way to get FirstName, LastName when one or both of the fields can be NULL?
CASE WHEN LastName+FirstName IS NOT NULL THEN ', ' END+
COALESCE(FirstName,'') AS Name
SELECT COALESCE(LastName + ', ' + FirstName, LastName, FirstName) Name FROM Person
lastname is null the entire first expression (with the
,), becomes null, forcing the coalesce to examine, second, the
lastname alone, and then if
lastname is null, finally, the