优先于列数据删除 SSIS 包中的重复项 [英] Remove duplicate in SSIS package with preference over a column data

查看:44
本文介绍了优先于列数据删除 SSIS 包中的重复项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在来自 Excel 工作表的数据中有重复的行.在 SSIS 包中,我使用排序转换,其中按主键列 ID 以升序进行排序.但在删除重复项之前,我想查看电子邮件列是否包含我公司域的电子邮件.如果是这样,我希望删除除具有此类电子邮件地址的行之外的其他行.我该怎么办?请参考下面的图片.

I have duplicate rows in data coming from excel sheet. In the SSIS package, I am using Sort transformation where sorting is done in ascending order by the primary key column ID. But before removing the duplicates I want to see if the email column has email with my company's domain. If so, I want other rows removed than the one having this type of email addresses. What should I do? Please refer to the image attached below.

在上面的数据中,我想删除电子邮件地址为 john@gmail.com 的两行 John.在 Maria 的情况下,我想删除电子邮件地址为 maria@gmail.com 的两行,从而保留电子邮件地址为域 mycompany.com 的行.如果用户的电子邮件地址为域 mycompany.com 的用户有多行,我想保留域电子邮件地址的任何一行.

In the data above, I want to remove two rows of John where email address are john@gmail.com. In Maria's case, I want to remove two rows having email addresses maria@gmail.com, hence preserving rows having email addresses of the domain mycompany.com. If there are multiple rows for a user having email addresses of the domain mycompany.com, I want to keep any one row with the domain email address.

请提出建议.

推荐答案

你可以像 Kobi 展示的那样在 sql 中做到这一点,这可能更容易.但是,如果您更喜欢 ssis:

you can do that in sql like Kobi showed, that may be easier. But if you prefer in ssis:

我的测试数据:

几点:

有条件的拆分:首先将带有 mycompany 的行和没有的行分开.

Conditional split: First you separate rows with mycompany and those without.

排序和 non_mycompany 排序:根据 id 对两个输出进行排序并删除重复项.

Sort and non_mycompany sort: sort both output on id and remove duplicates.

mycompany_multicast:用 mycompany 创建两个行的副本

mycompany_multicast: create two copy of rows with mycompany

合并连接:将没有 mycompany 的行左连接到有 mycompany 的行.注意连接顺序,目的是获取没有 mycompany 的行,并且在有 mycompany 的行中没有匹配的 id.

Merge join: left join rows without mycompany to rows with mycompany. Note the join order, the purpose is to get rows without mycompany and no matching id in rows with mycompany.

条件拆分 1:采用没有 mycompany 的行并且在有 mycompany 的行中没有匹配的 id.您可以使用 mycompany 从行中检查 id,如果 id 为空,则该行在与 mycompany 的行中没有匹配项.

Conditional split1: take rows without mycompany and no matching id in rows with mycompany. you can check id from rows with mycompany, if the id is null then the row has no matching in rows with mycompany.

union all:union 最终结果

union all: union the final result

这篇关于优先于列数据删除 SSIS 包中的重复项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆