create data script
drop table #Contacts
create table #Contacts
(
CustomerID INT,
CustomerName VARCHAR(100),
Country VARCHAR(100)
)
insert into #Contacts select 1 ,'Alfreds Futterkiste','Germany'
insert into #Contacts select 2 ,'Ana Trujillo Emparedados y helados' , 'Mexico'
insert into #Contacts select 3 ,'Antonio Moreno Taquería' ,'Mexico'
insert into #Contacts select 4 ,'Around the Horn' ,'UK'
insert into #Contacts select 5 ,'Berglunds snabbköp' ,'Sweden'
insert into #Contacts select 6 ,'Blauer See Delikatessen' ,'Germany'
insert into #Contacts select 7 ,'Blondel père et fils' ,'France'
insert into #Contacts select 8 ,'Bólido Comidas preparadas' ,'Spain'
insert into #Contacts select 9 ,'John' ,'Germany'
select * from #Contacts
drop table #CustomerExclusion
create table #CustomerExclusion
( CustomerID int, exclusion_type varchar(100), Flag varchar(1))
insert into #CustomerExclusion select 1 ,'BadAddress','Y'
insert into #CustomerExclusion select 1 ,'Optout','Y'
insert into #CustomerExclusion select 3 ,'NoCall','Y'
insert into #CustomerExclusion select 4 ,'BadEmail','Y'
insert into #CustomerExclusion select 5 ,'BadAddress','Y'
insert into #CustomerExclusion select 6 ,'BadAddress ','Y'
insert into #CustomerExclusion select 6 ,'Optout','Y'
insert into #CustomerExclusion select 9 ,'BadAddress','N'
select * from #CustomerExclusion
drop table #CustomerProfile
create table #CustomerProfile
( CustomerID INT,profile_attribute varchar(100), Flag varchar(1) ,Effective_Date date)
insert into #CustomerProfile select 1 ,'DOB ','Y ','11/19/2022'
insert into #CustomerProfile select 1 ,'DoNotContact ','Y ','10/25/2022'
insert into #CustomerProfile select 3 ,'AddressOnFile ','Y ','9/13/2022 '
insert into #CustomerProfile select 4 ,'SubscriptionPlanHolder ','Y ','8/8/2022 '
insert into #CustomerProfile select 5 ,'DOB ','N ','11/1/2022 '
insert into #CustomerProfile select 5 ,'DoNotContact ','Y ','10/2/2022 '
insert into #CustomerProfile select 5 ,'SubscriptionPlanHolder ','Y ','5/1/2022 '
insert into #CustomerProfile select 6 ,'DOB ','Y ','10/27/2021'
insert into #CustomerProfile select 6 ,'SubscriptionPlanHolder ','Y ','11/11/2022'
insert into #CustomerProfile select 6 ,'AddressOnFile ','N ','10/1/2022 '
insert into #CustomerProfile select 9 ,'DOB ','Y ','9/9/2022 '
insert into #CustomerProfile select 9 ,'SubscriptionPlanHolder ','N ','8/19/2022 '
select * from #CustomerProfile