Click here to Skip to main content
15,893,487 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
(Customer_first_name +'' ''+Customer_middle_name +'' ''+Customer_last_name)as CustomerName

If Customer_middle_name is null
eg:
Customer_first_name=raj
Customer_middle_name=null
Customer_last_name=kumar

The output comes
raj (2 space)kumar
but i want raj (1 space)kumar

so that Customer_middle_name is null to avoid space
Posted

1 solution

You can use COALESCE to select first non-null value. So in this case something like
SQL
COALESCE(Customer_first_name + ' ', '') 
+ COALESCE(Customer_middle_name + ' ', '') 
+ Customer_last_name AS CustomerName
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900