so you're trying to populate two destination tables based on a common source table? if yes, you might have to create view involving them for doing the same through merge. why dont you use normal upserts instead?DECLARE @INSERTED_COUNTRIES table(country varchar(100),country_id int)INSERT INTO DIM_COUNTRYOUTPUT INSERTED.country,INSERTED.country_id INTO @INSERTED_COUNTRIESSELECTUsage,country,region,ownership,enddate,users,sbu,sbg,sbe,buildingOriginFROMSAMPLE sLEFT JOIN DIM_COUNTRY cON c.country = s.countryWHERE c.country IS NULLINSERT INTO FCT_DETAILS SELECT ic.country_id,s.lid,s.Name,s.address,s.city,s.state,s.[area in sqft],s.latitude,s.longitude FROMSAMPLE sJOIN @INSERTED_COUNTRIES icON ic.country=s.countryLEFT JOIN FCT_DETAILS fdON fd.lid = s.lidWHERE fd.lid IS NULL
------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/