I've been tasked with converting several existing SQL scripts into SSIS packages. While some of the scripts are fairly straightforward, some of the scripts contain multiple JOIN's across multiple tables. While I have always just used a simple Execute SQL Task or an OLE DB source with a script, I've been asked to do away with any references to any other tables/databases in the source. Here is an example of one of the scripts:
INSERT INTO [dbo].[DimEngagementVehicle] ([EngagementVehicleSourceKey] ,[EngagementVehicleCode] ,[EngagementVehicleDesc] ,[EngagementVehicleCategorySourceKey] ,[EngagementVehicleCategoryCode] ,[EngagementVehicleCategoryDesc] ,[EngagementVehicleTypeSourceKey] ,[EngagementVehicleTypeCode] ,[EngagementVehicleTypeDesc] ,[GlobalEngagementVehicleKey] ,[GlobalEngagementVehicleDesc] ,[GlobalEngagementVehicleTypeKey] ,[GlobalEngagementVehicleTypeDesc] ,[RowIsCurrent] ,[RowStartDate] ,[RowEndDate] ,[RowChangeReason] ,[InsertAuditKey] ,[UpdateAuditKey] ) SELECT hs.health_screening_key ,hs.source_key ,hs.health_screening_desc ,s.source_key ,s.source_code ,s.source_desc ,v.rbh_vendor_key ,v.rbh_vendor_code ,v.rbh_vendor_name ,3 AS [GlobalEngagementVehicleKey] -- 'Health Screening ' ,'Health Screening ' AS [GlobalEngagementVehicleDesc] -- 'Health Screening ' ,2 AS [GlobalEngagementVehicleTypeKey] -- 'Active Engagement' ,'Active Engagement' AS [GlobalEngagementVehicleTypeDesc] ,'Y' AS [row_is_current] ,getdate() AS [row_start_date] ,'12/31/9999' AS [row_end_date] ,'N/A' AS [row_change_reason] ,-1 AS [insert_audit_key] ,-1 AS [insert_audit_key] FROM [RBH_DW_STAGE].[dbo].health_screening hs INNER JOIN [RBH_DW_STAGE].[dbo].[source] s on hs.source_key = s.source_key LEFT JOIN [RBH_DW_STAGE].[dbo].[rbh_vendor] v ON v.rbh_vendor_code = hs.vendor_screening_id WHERE NOT EXISTS (SELECT 1 FROM [DimEngagementVehicle] WHERE [GlobalEngagementVehicleTypeKey] = 2 AND [GlobalEngagementVehicleKey] = 3 AND [EngagementVehicleSourceKey] = hs.health_screening_key) GO
I know that either LOOKUP or MERGE JOIN could be used here, but not quite sure how to implement it in a package.
Any insight or assistance would be greatly appreciated!
Thanks!
A. M. Robinson