Hello Forum Members,
Data comes from upstream systems into Region_Import Table.
The RegionNames are checked with RegionName_Master table and the new Regions are to be sent as email. After New Region Name is found the RegionName_Master table is updated with the New RegionName. The email from SendMailTask always sends all the RegionNames rather than New RegionName. The #temp file should be dropped before select top1 from #test?
CheckTeamNames Script Task:
SELECT distinct RegionName into #temp
FROM [Region_IMPORT]
where RegionName not in (SELECT distinct [RegionName] FROM [RegionName_Master])
create table #test (RegionNames varchar(100))
insert into #test
SELECT STUFF((SELECT ',[' + regionnames + ']'
FROM #temp
FOR XML PATH (''))
,1,1,'')
Select top 1 * from #test
SendMailTask
[North],[NorthEast],[West],[MidWest]
Kind Regards,
Sqlquery9