Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


SSIS Duplicate Record Removal


SSIS Duplicate Record Removal

Author
Message
Niall Cronin
Niall Cronin
Grasshopper
Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)

Group: General Forum Members
Points: 20 Visits: 88
If anyone could help with the following I would greatly appreciate your help.

Basically I have a Data Flow Task.

I am moving data from one ole db source to another.

I would like to remove duplicate rows prior to being pushed in the the OLE Destination.

So my data might be something like this.

1 Employee1 Level 0
1 Employee1 Level 1
2 Employee2 Level 0
2 Employee2 Level 1
3 Employee3 Level 3
3 Employee3 Level 4

I want my output to be as follows:

1 Employee1 Level 0
2 Employee2 Level 0
3 Employee3 Level 3

Basically for each employee I if they appear twice i want to select the employee with the minimum level. I know this can be achieved using SQL however the volume of data in question makes this very difficult as doing a top, join, group by etc slow the system to a halt. I was hoping if i sorted my data in SSIS as it flow through the Dataflow that I could do something as follows :->

IF employee on this row = employee on previous row then discard this row.

If anyone nows how this can be achieved please let me know.

Thanking you in advance for any help you maybe able to provide.

Regards Niall
abhijeetv
abhijeetv
SSC-Addicted
SSC-Addicted (497 reputation)SSC-Addicted (497 reputation)SSC-Addicted (497 reputation)SSC-Addicted (497 reputation)SSC-Addicted (497 reputation)SSC-Addicted (497 reputation)SSC-Addicted (497 reputation)SSC-Addicted (497 reputation)

Group: General Forum Members
Points: 497 Visits: 510
Have you concluded that fixing this using SQL would affect perofrmance? (like using group by).

Otherwise using SQL similar to following can get you the desired result:

select * from YOURTABLE t where t.level = (select min(level) from YOURTABLE group by name having name=t.name)
Niall Cronin
Niall Cronin
Grasshopper
Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)

Group: General Forum Members
Points: 20 Visits: 88
Unfortunately SQL is not the desired option. Normally I would prefer to go this
method however in this case it is not feasable.

Cheers anyways mate.
Todd Engen
Todd Engen
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1081 Visits: 6336
Since you mentioned using a sort, chaining together two Sort components in the Data Flow would work. This would only make sense if SSIS was running on a server different from the source database though, otherwise SSIS would just be competing for resources with SQL.


[OLEDB Source] --> [Sort Component 1] --> [Sort Component 2] --> [OLEDB Destination]



Sort Component 1: Sort by EmployeeID (ASC) and LevelID (DESC).

Sort Component 2: Sort by EmployeeID (ASC) only, passing through Level ID, and select "Remove rows with duplicate sort values" in the Sort Transformation Editor dialog.

I don't see any statement in BOL about which duplicate is retained, but it appears the last one read is copied to the output.
Niall Cronin
Niall Cronin
Grasshopper
Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)

Group: General Forum Members
Points: 20 Visits: 88
Cheers. I actually ended up doing it in SQL using the RANK( ) function which worked quite well.

However the above looks a good solution and I will end up using it at some stage.

Cheers mate.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search