The query is used for inserting new records only.
How can I use this query? whether the sql script is inside the Execute SQL Task: SQL command task or OLE DB Source: SQL Command task when using 4 different Data sources(databases) such as database A,B,C and D.
In the Data Source under the Solution Explorer, I added four databases under one server, these are database A,B,C and D. Would it be possible to add four databases with four corresponding data source inside the OLE DB connection Manager??
OLE DB connection manager: Database/Data Source A, B, C, D <--- Is this possible??
Data Access Mode:
SQL Command
SQL Command Text:
Insert into DWResourceTask.dbo.DimEntity
select
a.EntCode,
a.Name,
a.Active,
a.AccessLevel,
a.SiteURN,
a.CompanyURN,
a.SiteName,
a.SiteDesc,
a.SiteURL
from
(Select e.EntCode, e.Name, e.Active, e.AccessLevel, ss.SiteURN, ss.CompanyURN,
ss.SiteName, ss.SiteDesc, ss.SiteURL
from A.dbo.Site ss, A.dbo.LegalEnt e
where ss.localsiteflag = 1
and e.active = 1
UNION ALL
Select e.EntCode, e.Name, e.Active, e.AccessLevel, ss.SiteURN, ss.CompanyURN,
ss.SiteName, ss.SiteDesc, ss.SiteURL
from B.dbo.Site ss, B.dbo.LegalEnt e
where ss.localsiteflag = 1
and e.active = 1
UNION ALL
Select e.EntCode, e.Name, e.Active, e.AccessLevel, ss.SiteURN, ss.CompanyURN,
ss.SiteName, ss.SiteDesc, ss.SiteURL
from C.dbo.Site ss, C.dbo.LegalEnt e
where ss.localsiteflag = 1
and e.active = 1
UNION ALL
Select e.EntCode, e.Name, e.Active, e.AccessLevel, ss.SiteURN, ss.CompanyURN,
ss.SiteName, ss.SiteDesc, ss.SiteURL
from D.dbo.Site ss, D.dbo.LegalEnt e
where ss.localsiteflag = 1
and e.active = 1
)a
where not exists (select * from DWResourceTask.dbo.DimEntity w
where(a.EntCode=w.EntCode
and a.Name=w.Name
and a.Active=w.Active
and a.AccessLevel=w.AccessLevel
and a.SiteURN=w.SiteURN
and a.CompanyURN=w.CompanyURN
and a.SiteName=w.SiteName
and a.SiteDesc=w.SiteDesc
and a.SiteURL=w.SiteURL))
Please Help. Thanks in Advance!
I will elaborate on the Data Flow task for you. Hopefully this helps.
Within the Data Flow task, add your origin (Source) and destination. These can be flat files, database connections, etc.
Within the origin, select the Connection and columns you'd like to include.
Open up your destination and select the Connection and table to which the data is going to go.
Next, map the origin columns to the destination columns. You can do this manually, or by right-clicking and Matching on Name. That's it for that connection.
Repeat this process for your other Source and Destinations as part of your overall process flow.
Test your SSIS package, then deploy.