Hi Ron,
You can take a look at the
coalesce function. This functions returns the first none null element you pass to it. Since adding a space to null still results in null, you could do it like this:
SELECT FirstName + coalesce(' ' + Initials + ' ', ' ') + LastName AS FullName FROM Users
This will test Initials. When it's not null, a space followed by the initials followed by another space is returned. If the initials are null, just a single space (to separate the first name from the last name) is returned.
You can change the stuff you pass to coalesce if other fields can be null as well. In that case, you don't want the initials to be responsible for adding the spaces.
Hope this helps,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to:
Thirty-Three by
Smashing Pumpkins (Track 3 from the album:
Mellon Collie and the Infinite Sadness - Twilight to Starlight)
What's This?