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

本文详细介绍了如何使用SSIS(SQL Server Integration Services)的条件拆分转换任务来根据特定条件将数据拆分到不同的表中。通过创建SSIS包,作者演示了如何从AdventureWorks2017数据库的员工数据中,根据CountryRegionName字段将数据拆分为针对英国、美国和德国的单独表,并将不符合条件的数据放入默认表。文章强调了SSIS在简化数据处理和避免复杂编程方面的作用。
摘要由CSDN通过智能技术生成

ssis 有条件拆分

This article explores the SSIS Conditional Split Transform task to split data into multiple destinations based on the specified conditions.

本文探讨了SSIS条件拆分转换任务,该任务可根据指定条件将数据拆分到多个目标。

介绍 (Introduction)

We apply different logics on data in SQL Server tables to fulfill the requirements of the end-users. We might apply different analytical, logical, arithmetic conditions and logic on data. Let’s say you have a requirement to split the data into multiple tables depending upon some conditions. You can use a T-SQL function to write, but it might take time to do the development work. You need to rework on the code in case there are logic changes.

我们对SQL Server表中的数据应用不同的逻辑,以满足最终用户的需求。 我们可能会对数据应用不同的分析,逻辑,算术条件和逻辑。 假设您需要根据某些条件将数据拆分为多个表。 您可以使用T-SQL函数进行编写,但是可能需要一些时间来完成开发工作。 如果发生逻辑更改,则需要对代码进行重新处理。

SSIS always comes handy in such situations and provides a solution for us with minimal complexity. Further, we can use it to take inputs from multiple data sources such as Excel, CSV, OLE DB, ODBC, TXT, etc. We can also use it to prepare output in different formats without writing complex programming codes.

在这种情况下,SSIS总是很方便,并为我们提供了最小的复杂性的解决方案。 此外,我们可以使用它来获取来自多个数据源的输入,例如Excel,CSV,OLE DB,ODBC,TXT等。我们还可以使用它来准备不同格式的输出,而无需编写复杂的编程代码。

环境细节 (Environment Details)

需求 (Requirement)

We have Employee data in the AdventureWorks2017 database. It contains a view vEmployee to fetch employee records.

我们在AdventureWorks2017数据库中有员工数据。 它包含一个视图vEmployee以获取员工记录。

Execute the following query to view the sample data.

执行以下查询以查看样本数据。

SELECT *
    FROM [AdventureWorks2017].[HumanResources].[vEmployee];

Sample Data

We want to split data based on the CountryRegionName column in different tables.

我们要基于不同表中的CountryRegionName列拆分数据。

  • For employees belonging to the United Kingdom, insert data into the table [United Kingdom]

    对于属于英国的雇员,将数据插入表[英国]
  • For employees belonging to the United States, insert data into the table [United States]

    对于属于美国的雇员,将数据插入表[美国]
  • For employees belonging to Germany, insert data into the table [Germany]

    对于属于德国的雇员,将数据插入表中[德国]
  • The rest of the data (not satisfying above conditions) should go to the [default] table

    其余数据(不满足上述条件)应转到[默认]表

创建一个SSIS包以根据条件拆分数据 (Create an SSIS package to split data based on conditions)

将SSIS条件拆分转换添加到数据流 (Add an SSIS Conditional Split Transformation to the Data Flow)

Let’s use the SSIS package to satisfy the above conditions and split data in multiple tables.

让我们使用SSIS包来满足上述条件并将数据拆分到多个表中。

  • Open SQL Server Data Tool and go to File->New -> Project

    打开SQL Server数据工具,然后转到“文件”->“新建”-&

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值