Skip to main content

SSIS_Incremental Loading

1.Incremental loading using Lookup Transformation 

In this demo we use EID as the primary key in the source table.

In the first lookup we match the primary key. The NoMatched data is inserted and the matched data is updated.


For updating the data in SSIS OLEDB command task.




Mapping the parameters to the columns.


For Lookup unmatched row we update. We dont update for all the rows. so we are adding one more lookup with all the columns in the lookup transformation. After this we fiter only the Data which is notmatched.


So in the second lookup tranformation(marked abv) we map all the columns.


Post that we only take the No Matched data and update it. 


If you want to add another column in the source table(in sql side you use the below) 



For adding the same Ins_date column in the DWH table we use Derived Column transformation as below.



Hence the full package for Incremental Loading is ready.

2.Incremental Loading using SCD 

Type 0 = Change is treated as error
Type 1 = The row is updated 
Type 2 = It will capture the history of a row

To implement type 2 on a column, we need to remove the Primary key as this will throw errors , instead on Primary key we will include a Surrogate Primary key.





After finishing the task, SCD will create the incremental package by itself.

3. Incremental Loading using Merge Statement.

Merge statement is a combination statement that can perform INSERT, UPDATE, DELETE statements based on whether rows that match the selection criteria exists in the table or not.



MERGE Target_TAble as target
USING Source_Table as Source
On Condititon
When Matched THEN
UPDATE
SET Column = Source.Column,
WHEN TARGET IS NOT MATCHED THEN
INSERT Values ( Source.Column1 , Source.Column2)

Merge DimEmp as D
Using Emp as S
On S.EID = D.EID

--Update
When Matched and ( D.name <> S.name or D.Salary <> S.Salary )
Then 
Update 
Set D.name = s.name , D.Salary = s.salary

--Insert
When Not Matched by Target
Then
Insert ( Eid, Name, Salary) Values (S.eid, S.name, S.Salary);


This the way in which Incremental loading is done using the Merge Command.


Popular posts from this blog

How to remove special characters in the Data(using Script component Task and Regex)

Start with the Below screen shot ( Before Script Task) and you will come to know about the senario. Note : The Script Component also works for the special characters within the Data as well . for ex "A$hish" Hover over the below Regex. it will show > Show potential fixes > in that Select System.Text.RegularExpressions. The Below will disappear.  Use the Below Script.  public override void Input0_ProcessInputRow(Input0Buffer Row) { Row.CustomerID = RemoveSpecialCharacters(Row.CustomerID); Row.NameStyle = RemoveSpecialCharacters(Row.NameStyle); Row.Title = RemoveSpecialCharacters(Row.Title); Row.FirstName = RemoveSpecialCharacters(Row.FirstName); Row.LastName = RemoveSpecialCharacters(Row.LastName); Row.CompanyName = RemoveSpecialCharacters(Row.CompanyName); Row.SalesPerson = RemoveSpecialCharacters(Row.SalesPerson); Row.EmailAddress = RemoveSpecialCharacters(Row.EmailAddress); Row.Phone = RemoveSpecialCharacters(Row.Phone); } public static string ...

DBMS

Database : database can be defined as a collection of information stored at a particular place written in a predetermined manner, belongs to a particular topic.  DBMS: (DATA BASE MANAGEMENT SYSTEM):  it is defined as software which is present inside the database which is used o maintain or manage the data within the database .                                 In the above diagram, if the user needs any info from the database. He has to contact with  dbms , then the dbms goes to the database, takes the information from the  database and gives it back to the user. Database models :  these models are broadly divided into the following types: 1.         FMS/FDMS 2.         HMS/HDMS 3.         NDBMS 4.         RDBMS 5.      ...

Different Schemas in DWH

  SCHEMAS:   Star Schema: -       Star Schema means Dimension Tables are directly linked to the Fact Table. Snow Flake Schema: -       Dimension Tables are indirectly linked to the Fact Table OR -       Dimension table is linking to another dimension table .       Star Schema   Snow Flake Schema 1 Has redundant data and hence tough to maintain/change 1 No redundancy and hence more easy to maintain/change 2 Less complex queries and hence easy to understand 2 More complex queries and hence less easy to understand 3 Less foreign keys so faster execution time of cube. 3 More foreign keys so take more execution of cube 4 Has De-Normalized Tables 4 Has Normalized Tabl...