SQL to Concat strings and then remove blank spaces
09:45 24 Sep 2018

I am trying to work out how to concat multiple fields, removing any spaces between them and then comparing them to another value.

I have the following fields : Address1, Town, County & Postcode. Basically i need these strings concatenated and then removing any white space etc. Can someone please show me how i would do this within my the following sql i have here:

select distinct p.GtId,
    p.CrmPartyId,
    p.LegalName,
    p.BusinessClass,
    p.RmFullName,
    p.PbeFullName,
    p.OverallClientStatus,
    p.OverallRpStatus,
   a.AddressType
from CORE.WeccoParty p
    join CORE.WeccoPartyAddress a ON p.GtId = a.GtId
where exists (select 1
           from CORE.WeccoParty sub_p
           left join CORE.WeccoPartyAddress sub_a 
             on sub_p.GtId = sub_a.GtId 
           where (p.FirstName     =  sub_p.FirstName
                  and p.LastName  =  sub_p.LastName
                  and a.Address1=  sub_a.Address1
                  and a.Town = sub_a.Town
                  and a.County = sub_a.County
                  and a.Postcode = sub_a.Postcode
                  and a.GtId           <> sub_a.GtId)
          )
sql sql-server string