I used it for MSSQL, I personally donβt like it, but for this one report or data task it does the trick.
declare @team table (team_id int,email_list varchar(8000)); declare @persons table (person_id int,email varchar(64)); insert into @team SELECT 1,' bob@domain.com , jane@domain.com ' union all SELECT 2,' ben@domain.com , jane@domain.com ' union all SELECT 3,' ben@domain.com , james@domain.com ' union all SELECT 4,' bill@domain.com , alice@domain.com , peter@domain.com ' UNION ALL SELECT 3,' alben@domain.com , james@domain.com ' ; insert into @persons select 1,' james@domain.com ' union all select 2,' ben@domain.com ' union all select 3,' alice@domain.com '; select Team.team_id, Team.email_list, Person.person_id, Person.email 'matched_on' from @team Team INNER JOIN @persons Person on ','+Team.email_list+',' LIKE '%,'+Person.email+',%';
Updated by David
source share