COALESCE and CONCAT Address Line 1 and Address Line 2 separated by a comma

Bobby P 221 Reputation points
2024-05-09T18:55:45.0266667+00:00

We are trying to COALESCE and CONCAT Address Line 1 and Address Line 2 separated by a comma "," from potentially two data sources.

So like...123 Main St., Apt. 101

The first part is easy enough...

CONCAT (

COALESCE (

LTRIM (RTRIM ([Temp_Table_State_Funded_NonMedicaid_EDW_Member_Subset].[EDW_Address_AddressLine1])),

LTRIM (RTRIM ([#Temp_Table_State_Funded_NonMedicaid_EDW_Eligibility_Span].[EDW_MemberEligibility_CardAddress1])),

''

),

So how do we do the second part and COALESE and CONCAT based on the Address Line 2 being valued and preceded by a comma "," if Address Line 2 is from two different sources?

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,853 questions
SQL Server Transact-SQL
SQL Server Transact-SQL
SQL Server: A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.Transact-SQL: A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
48 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,560 questions
{count} votes