In a table, there 3 columns: GivenName, FamilyName, MiddleName
. And I have to append all three columns values to output a single column like this
Select Upper(GivenName) + FamilyName + Upper(MiddleName) as PersonName.....
But if value for any one of the column is null then the whole output is Null.
Any way if I can check if any of the column is null before appending? So that it is not appended and others which are not null gets appended.
But I cannot use 'where GivenName is not null, FamilyName is not null' condition.
I just dont want to append the string which is null. For Ex:
If GivenName = 'Mark',
FamilyName = 'Joseph',
MiddleName is null
Then output should be : MARK Joseph instead of NULL which has not appended MiddleName as it is Null.
(But in SQL it the output is NULL. Try this..
declare @FirstName nvarchar(20);
declare @GivenName nvarchar(20);
declare @MiddleName nvarchar(20);
set @FirstName = 'Steve';
set @GivenName = 'Hudson';
set @MiddleName = null;
select Upper(@FirstName) + @GivenName + UPPER(@MiddleName)
=> Outputs Null
)