Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi experts,


BM_Address_Eng1    BM_Address_Eng2            BM_Address_Eng3          BM_Address_pin
G/O SOSAWWA     G HULIKATTI VILLAGE-        KALGHATGI TALUK          574101

how to combine these columns to a single address column
like


Address
G/O SOSAWWA   G HULIKATTI VILLAGE-  KALGHATGI TALUK  574101

Please help me to get the output as mentioned above.
Here sometimes BM_Address_Eng2 may be having null value.

Thanking You
(Keerthi Kumar)
Posted

The problem lies in 'BM_Address_Eng2 may be having null value.', so try this:
SQL
select  BM_Address_Eng1 + isnull(BM_Address_Eng2, '') + BM_Address_Eng3 + BM_Address_pin
from table1;
 
Share this answer
 
Comments
[no name] 22-Mar-14 6:16am    
+5
Peter Leow 29-Mar-14 2:42am    
Thank you.
select (column1+', '+column2+' ,'+column3+','+column4)as address from table

else go for Concatenate
 
Share this answer
 
Just like your output if you need some spaces between each column, then little modification in above query

select BM_Address_Eng1 +' ' + isnull(BM_Address_Eng2, '') +' ' + BM_Address_Eng3 +' ' + BM_Address_pin
from table1;
 
Share this answer
 

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