May 8, 2008 at 3:39 am
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
May 8, 2008 at 4:21 am
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)
May 8, 2008 at 4:37 am
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.
May 8, 2008 at 11:06 am
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.
May 9, 2008 at 2:12 am
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.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply