Мне нужно выяснить, как объединить почтовые адреса в следующем формате:
address1 address 2 (sometimes not present) city state zip5 - zip4 (sometimes not present
Я попытался сделать это на примере, который нашел в Интернете:
Stuff(
Coalesce(' ' + Buyer_Address1, '') +
Coalesce(' ' + Buyer_Address2, '') +
Coalesce(' ' + Buyer_City, '') +
Coalesce(' ' + Buyer_State, '') +
Coalesce(' ' + Buyer_ZipFive, '') +
Coalesce('-' + Buyer_ZipFour, ''), 1, 1, '') AS [MailingAddress]
Комуэти адреса:
Address 1 Address 2 City State Zip
210 Independence Blvd Tucson AZ 85641
1 Palace Lane Suite A Toad Kingdom FL 37058
123 Star Lane Star Kingdom OH 54678
Но результаты таковы:
210 Independence Jr Blvd Tucson AZ 85641-
1 Palace LaneSuite A Toad Kingdom FL 37058-
123 Star Lane Star Kingdom OH 54678-
Любая помощь в решении этих проблем будет велика.
Спасибо, любезно.