ssis 有条件拆分

SQL Server Integration Services or SSIS is used as an ETL tool to extract-transform-load data from heterogeneous data sources to different databases. After extracting data from the different sources, most often there are a lot of transformations needed. One of the frequent transformations is SSIS Conditional Split.

SQL Server Integration Services或SSIS用作ETL工具,用于将数据从异构数据源提取转换加载到不同的数据库。 从不同来源提取数据后,通常需要进行很多转换。 常见的转换之一是SSIS条件拆分。

情境 (Scenario)

Let us assume we have a set of employees, who has different payment types such as Permanent, Temporary, and Commission bases. As you know, different payment types need different calculations. Let us assume following is the data set.

让我们假设我们有一组员工,他们具有不同的付款类型,例如永久性,临时性和佣金基数。 如您所知,不同的付款类型需要不同的计算。 让我们假设以下是数据集。

Now the requirement is to perform the calculation for different payment types. This means that you need to split this data set into different payment types and they perform the relent calculation.

现在,要求对不同的付款类型执行计算。 这意味着您需要将此数据集划分为不同的付款类型,然后它们执行剩余的计算。

SSIS实施 (SSIS Implementation)

Let us implement this in SSIS.

让我们在SSIS中实现这一点。

First, create an SSIS project in Visual Studio and open the existing DTSX package.

首先,在Visual Studio中创建一个SSIS项目,然后打开现有的DTSX包。

Since this is a data flow task drag and drop Data Flow Task to the control flow as shown in the below image.

由于这是一个数据流的任务拖放数据流任务的控制流程中所示的下面图像英寸

Then double-click the Data Flow Task which will open in the data flow pane.

然后双击将在数据流窗格中打开的数据流任务

Since we are extracting data from a text a file, let us create a connection to the text file and create a source for it from the Flat file Source.

由于我们要从文本文件中提取数据,因此让我们创建与文本文件的连接,并从平面文件源中为其创建源。

Since this text file is a comma-separated value, the Delimited format is selected which is the default setting in the flat file connection along with the other default settings.

由于此文本文件是逗号分隔的值,因此选择了“分隔格式”,这是平面文件连接中的默认设置以及其他默认设置。

Following is the sample data set which can be seen after setting up the flat file connection.

以下是设置平面文件连接后可以看到的示例数据集。

Now we are ready to separate incoming data set to different payment types.

现在,我们准备将传入数据集分离为不同的付款类型。

SSIS条件拆分控制 (SSIS Conditional Split Control)

SSIS Conditional Split control can be seen in the SSIS toolbox under the Common category as shown in the below image.

SSIS条件拆分控件可以在SSIS工具箱的“通用”类别下看到,如下图所示。

Drag and drop the SSIS Conditional Split control to the data flow and connect with the flat file connection as shown below.

将SSIS条件拆分控件拖放到数据流中,并与平面文件连接进行连接,如下所示。

As shown in the above image, SSIS Conditional Split control is renamed to Split for Different Pay Types for better readability.

如上图所示,SSIS条件拆分控件已重命名为“拆分”以用于不同的付款类型,以提高可读性。

Next is to configure the SSIS Conditional Split Control which can be done by double-clicking the Conditional Split Control.

接下来是配置SSIS条件拆分控件,可以通过双击条件拆分控件来完成。

Above are most of the important configurations in the SSIS Conditional Split Control. In this configuration page, you need to provide the condition which will be used to split the data set. Scripting in the conditional split configuration needs the VBScript format.

以上是SSIS条件拆分控制中的大多数重要配置。 在此配置页面中,您需要提供将用于拆分数据集的条件。 条件拆分配置中的脚本需要VBScript格式。

In the above configuration, three conditions are configured. In this configuration, the dataset is divided into three conditions. Developers have the option of drag and drop the column names from the above to the condition which will become much easier for the developers. These conditions can incorporate with inbuilt string functions, mathematical functions, Date/Time functions, NULL functions.

在以上配置中,配置了三个条件。 在此配置中,数据集分为三个条件。 开发人员可以选择将列名从上面拖放到条件,这对开发人员来说将变得更加容易。 这些条件可以与内置的字符串函数,数学函数,日期/时间函数,NULL函数结合使用。

Though the above configurations are fairly straightforward, there can be instances where the split condition can be complexed. When there is a complex condition, there can be instances where one record may fall into multiple conditions. Due to the Priority order, when a record satisfies a condition, it will not be evaluated again.

尽管上述配置非常简单,但是在某些情况下,拆分条件可能会很复杂。 当情况复杂时,可能会出现一条记录可能属于多种情况的情况。 由于优先顺序,当记录满足条件时,将不会再次对其进行评估。

In the above configuration, there is a Default output name called Other. This is to transfer all records which do not fall into any of the above conditions. This means that all the records coming into the SSIS Conditional Split control will be output from the control.

在以上配置中,有一个默认输出名称,称为其他。 这是为了转移不属于上述任何条件的所有记录。 这意味着进入SSIS条件拆分控件的所有记录都将从该控件输出。

Next is to configure the output from the SSIS Conditional Split.

接下来是配置SSIS条件拆分的输出。

As you can see in the above screenshot, there are four paths coming out from the SSIS Conditional Split control.

从上面的屏幕快照中可以看到,SSIS条件拆分控件提供了四个路径。

As seen from the above screenshot, the output is split into four paths and after this, each path is independent of the other path. This means that different transformations can be done for different paths as seen in the following image after executing the package.

从上面的屏幕截图可以看出,输出被分为四个路径,此后,每个路径都独立于另一个路径。 这意味着可以在执行程序包后对不同的路径进行不同的转换,如下图所示。

As shown in the above screenshot, all eight records are split into four paths. Relevant records can be viewed by enabling data viewer at the relevant path.

如上面的屏幕快照所示,所有八个记录都分为四个路径。 通过在相关路径上启用数据查看器 ,可以查看相关记录。

最佳实践 (Best Practices)

Most of the time, developers forget to configure the Other path as shown in the above example. Most of the time, developers will configure the split conditions for their requirement. However, with overtime, when there is a new configuration comes to the data source, this will not be considered. The better option would be, at least move the default path to the audit log so that it can be viewed different times to identify whether those records need to be considered so that conditions can be modified accordingly.

在大多数情况下,开发人员会忘记如上例所示配置“其他”路径。 在大多数情况下,开发人员将根据自己的需求配置拆分条件。 但是,随着时间的流逝,当数据源有新配置时,将不考虑这一点。 更好的选择是,至少将默认路径移至审核日志,以便可以在不同时间查看该日志,以确定是否需要考虑这些记录,以便可以相应地修改条件。

结论 (Conclusion)

Always remember to configure the error output. This applies to every transformation in SSIS. Since you are dealing with data which you don’t have control over, you don’t know what are the data coming in. Therefore, it is always better to configure the error and redirect to a different target.

始终记得配置错误输出。 这适用于SSIS中的每个转换。 由于您正在处理无法控制的数据,因此您不知道输入的数据是什么。因此,最好配置错误并重定向到其他目标。

翻译自: https://www.sqlshack.com/ssis-conditional-split-overview/

ssis 有条件拆分

ssis 有条件拆分_SSIS条件拆分概述相关推荐

  1. ssis 有条件拆分_SSIS条件拆分转换概述

    ssis 有条件拆分 This article explores the SSIS Conditional Split Transform task to split data into multip ...

  2. ssis修改数据库数据_SSIS平衡数据分配器概述

    ssis修改数据库数据 In this article, we will give a brief overview of SSIS Balanced Data Distributor (BDD). ...

  3. ACM中的整数K拆分 (有条件限制 无条件限制 插板法 URAL-1036 HDU-6397)

    整数的K拆分 整数K拆分示例 在程序设计竞赛中,我们会经常遇到一类整数 KKK 拆分的问题. 例如:求 NNN 个非负整数之和为 SSS 的方案数(每个数字都小于 MMM). 对于这类问题,分为两种情 ...

  4. 将工作表按条件拆分成多个工作表或者工作簿,包含快速拆分与精致拆分

    将一个工作表按条件拆分成多个工作表或者拆分成工作簿,包含快速拆分与精致拆分. 精致拆分可以保留所有格式,速度慢一点. 可以将一个工作表拆分成多个工作表,也可以直接拆分成多个独立文件. 将工作表按条件拆 ...

  5. 数据切分 垂直切分、垂直拆分与水平拆分的优缺点

    数据切分 垂直切分 关于数据库的水平切分和垂直切分的一些概念垂直拆分垂直拆分就是要把表按模块划分到不同数据库表中(当然原则还是不破坏第三范式),这种拆分在大型网站的演变过程中是很常见的.当一个网站还在 ...

  6. 【组合数学】生成函数 ( 正整数拆分 | 重复有序拆分 | 不重复有序拆分 | 重复有序拆分方案数证明 )

    文章目录 一.重复有序拆分 二.不重复有序拆分 1.无序拆分基本模型 2.全排列 三.重复有序拆分方案数证明 参考博客 : 按照顺序看 [组合数学]生成函数 简要介绍 ( 生成函数定义 | 牛顿二项式 ...

  7. Mysql 分表 垂直分割_图文解释 读写分离、垂直拆分、水平拆分、分库分表

    1. 前言 相信你经常被 读写分离.垂直拆分.水平拆分.分库分表 这几个名词搞得很懵逼.我有时候也很懵逼,那么今天就来把这几个数据库常用术语搞清楚,同时也记录一下. 2. 读写分离 这个相对比较好理解 ...

  8. 数据库的垂直拆分和水平拆分

    2019独角兽企业重金招聘Python工程师标准>>> 当我们使用读写分离.缓存后,数据库的压力还是很大的时候,这就需要使用到数据库拆分了. 数据库拆分简单来说,就是指通过某种特定的 ...

  9. 数据库和数据库表的水平拆分和垂直拆分

    数据库垂直拆分(按照功能模块拆分) 数据库水平拆分(根据某种规则划分,比如对id取余) 数据库表的垂直拆分 数据库表的水平拆分 数据拆分前其实是要首先做准备工作的,然后才是开始数据拆分 第一步:采用分 ...

最新文章

  1. python轨迹追踪、全链路日志追踪trace_id实现
  2. 天体运行轨迹_海王星轨道外发现139个新天体, 能揭开太阳系第九颗行星奥秘?...
  3. 73. 解决ExtJS TreePanel 的 iconCls设置问题
  4. 配电基础知识汇总,99%的人都收藏了!
  5. 安装Fontawesome4字体图标
  6. error CS1002: ; expected 错误解决
  7. 纵坐标范围_探索频率范围与频响的奥秘
  8. c语言怎么加分数,用C语言编程平均分数
  9. 蓝桥杯java龟兔赛跑_蓝桥杯 1476: [蓝桥杯][基础练习VIP]龟兔赛跑预测
  10. centos7图形化界面安装KVM虚拟机
  11. 目录_计算机视觉中的数学方法
  12. SQL数据导出至Excel
  13. html input 密文,HTML input text框显示为密文
  14. 新生儿的二类(自费)疫苗(截止2019年)
  15. VC中用代码移动CDockPane的位置
  16. HTTP协议:三.HTTP 报文信息
  17. python 自动发微博_用 Python 自动定时发微博
  18. 民族企业家周景川:凡事勤则易,凡事惰则难
  19. 中国工程院院士高文:从大数据科学到人工智能的迁移过程
  20. BEV最新综述 | 学术界和工业界方案汇总!优化方法与tricks

热门文章

  1. suse linux系统备份,suse linux enterprise server 11 sp3 版克隆安装ebs r12.1.3注意事项
  2. 北信源管理网页卸载密码_怎么卸载找不到程序的流氓软件?
  3. logstash grok切分nginx日志
  4. Fence Repair (poj3253)
  5. python单例设计模式(待补充)
  6. 【并行计算-CUDA开发】关于共享内存(shared memory)和存储体(bank)的事实和疑惑...
  7. SQL Server 2008 R2:error 26 开启远程连接详解
  8. [SecureCRT] 解决 securecrt failed to open the host key database file 的问题
  9. 【王道考研操作系统】—文件的基本操作
  10. vuetify中文文档_我们为什么选择Vuetify作为前端框架