ssis 列转换

This article explores the SSIS Multicast Transformation for creating different logical copies of source data.

本文探讨了用于创建源数据的不同逻辑副本的SSIS组播转换。

介绍 (Introduction)

In the article, SSIS Conditional Split Transformation overview, we explored the Conditional Split Transformation task to split the incoming data into multiple destinations depending upon the specified condition. We use SSIS Multicast Transformation to create multiple copies of input data. Suppose we require multiple copies of the input data in TXT, CSV and SQL table format. We can use these multiple copies of the data for different transformations.

在SSIS条件拆分转换概述文章中,我们探索了条件拆分转换任务,以根据指定条件将传入数据拆分为多个目标。 我们使用SSIS组播转换来创建输入数据的多个副本。 假设我们需要TXT,CSV和SQL表格式的输入数据的多个副本。 我们可以将这些数据的多个副本用于不同的转换。

Suppose you receive stock transactions for your clients in a CSV format. You upload the data in the database and do the calculations for your clients depending upon multiple scenarios. You can use SSIS Multicast Transformation to prepare similar copies of data using SSIS. We do not need any programming or development experience to do this task.

假设您以CSV格式收到客户的股票交易。 您将数据上传到数据库中,并根据多种情况为客户进行计算。 您可以使用SSIS组播转换来使用SSIS准备数据的相似副本。 我们不需要任何编程或开发经验即可完成此任务。

Let’s create an SSIS package to use the SSIS Multicast Transformation.

让我们创建一个SSIS包以使用SSIS组播转换。

环境细节 (Environment Details)

  • Github Github下载该数据库的副本
  • Download and install SQL Server Data Tools (SSDT) for Visual Studio and install it 下载并安装Visual StudioSQL Server数据工具(SSDT)”并安装它

In the following image, you can see the configured SQL Server Data Tools for my system.

在下图中,您可以看到为我的系统配置SQL Server数据工具。

创建用于SSIS组播转换的SSIS包 (Create an SSIS package for SSIS Multicast Transformation)

Launch SQL Server Data Tool to create an Integration project. Provide the Integration project name and specify the location to save the project.

启动SQL Server数据工具以创建一个集成项目。 提供集成项目名称,并指定保存项目的位置。

在连接管理器中添加OLE DB源 (Add an OLE DB Source in the Connection Manager)

In the SSIS project window, we have the following areas.

在SSIS项目窗口中,我们具有以下区域。

  1. Control Flow, Data Flow, Event Handlers and Package Explorer area 控制流,数据流,事件处理程序和包资源管理器区域
  2. We add different SSIS components in this area

    我们在此区域添加了不同的SSIS组件

  3. In the Connection Managers area, we can configure the different source and destination connections. You can also view all the connections in the package in this area 在“连接管理器”区域中,我们可以配置不同的源连接和目标连接。 您也可以在此区域查看软件包中的所有连接

Let’s add an OLE DB Source connection to point the WideWorldImporters database in my local instance. Right-click on the Connection Managers, click on New OLE DB Connection.

让我们添加一个OLE DB Source连接以在我的本地实例中指向WideWorldImporters数据库。 右键单击“连接管理器”,然后单击“ 新建OLE DB连接”

It opens the OLE DB Connection Manager. Provide the details such as SQL Instance name, Authentication method (Windows or SQL authentication) and select the database name from the drop-down list.

它打开OLE DB连接管理器。 提供详细信息,例如SQL实例名称,身份验证方法(Windows或SQL身份验证),然后从下拉列表中选择数据库名称。

You can test the connection and click Ok. You can see the configured connection in the Connection Managers area.

您可以测试连接,然后单击“确定”。 您可以在“连接管理器”区域中看到已配置的连接。

For a better understanding, right-click on this connection and rename it with an appropriate name.

为了更好地理解,请右键单击此连接,然后使用适当的名称重命名。

Drag the Data Flow Task in the Control Flow area.

将数据流任务拖到“控制流”区域中。

Right-click on the Data Flow Task and click on Edit.

右键单击“数据流任务”,然后单击“编辑”。

It moves to the data Flow page. In the Data Flow page, add an OLE DB Source similar to the following image.

它将移至数据流页面。 在“数据流”页面中,添加类似于下图的OLE DB源。

Double click on this to open the OLE DB Source editor. It automatically shows the connection we created earlier. If we want a separate connection, you can click on New and configure it. In the Data access mode, select the Table or View because my source data is in the SQL table.

双击打开OLE DB Source编辑器。 它会自动显示我们之前创建的连接。 如果我们需要单独的连接,则可以单击“新建”并进行配置。 在数据访问模式下,选择表或视图,因为我的源数据在SQL表中。

Select the table that contains the data. I selected Sales.Orders table from the WideWorldImporters database.

选择包含数据的表。 我从WideWorldImporters数据库中选择了Sales.Orders表。

Click Ok and rename the OLE DB Source to Source Data.

单击确定,并将OLE DB源重命名为源数据。

添加SSIS组播转换以配置多个目标 (Add SSIS Multicast Transformation to configure multiple destinations)

Drag the Multicast transformation to the data flow tab and join the green line from Source Data to Multicast.

将“多播”转换拖到“数据流”选项卡上,并将绿线从“源数据”连接到“多播”。

Now we want to add three destinations.

现在我们要添加三个目的地。

  • Flat File output 平面文件输出
  • Excel file output Excel文件输出
  • SQL Database table SQL数据库表

在SSIS组播转换中添加FLAT文件输出 (Add a FLAT file output in the SSIS Multicast Transformation)

We use Flat File Destination for the TXT or CSV file formats. Drag the Flat File Destination from the SSIS Toolbox to Data Flow task and join it with the Multicast operator.

我们将平面文件目标用于TXT或CSV文件格式。 将平面文件目标从SSIS工具箱拖到数据流任务,并将其与多播运算符一起加入。

It shows the Red Cross icon on Flat File Destination because we did not configure the destination. Double click on it, and it launches the Flat File Destination Editor.

它在平面文件目标上显示红十字图标,因为我们没有配置目标。 双击它,它会启动平面文件目标编辑器。

Click on New, and it asks for the flat-file format. We can choose the formats below.

单击“新建”,然后要求提供平面文件格式。 我们可以选择以下格式。

  • Delimited 定界
  • Fixed Width 固定宽度
  • Fix Width with row delimiters 使用行定界符修复宽度
  • Ragged Right 衣衫Right的权利

Let’s go with the default format Delimited. In this format, the commas delimit the columns in the text file.

让我们使用默认格式Delimited。 在这种格式下,逗号分隔文本文件中的列。

Click Ok, and it opens the Flat File Destination editor. Specify the connection name and the file path. It automatically gives the format specifications such as Header Row delimiter, Text qualifier. We will go with the default values.

单击确定,它将打开平面文件目标编辑器。 指定连接名称和文件路径。 它会自动给出格式规范,例如标题行定界符,文本限定符。 我们将使用默认值。

In the Advanced page, we view the source columns and their properties for the destination flat file.

在“高级”页面中,我们查看目标平面文件的源列及其属性。

Click on Mapping to view the mapping of input and output columns. By default, it does the mapping; however, we can change it if required.

单击映射以查看输入和输出列的映射。 默认情况下,它会进行映射。 但是,如果需要,我们可以更改它。

Click Ok, and we can see the Red Cross icon is not present now on Flat File Destination.

单击确定,我们可以看到“平面文件目标”上现在不存在“红十字”图标。

在SSIS组播转换中添加Excel文件输出 (Add an Excel file output in the SSIS Multicast Transformation)

Let’s add an Excel file destination from the SSIS toolbox and join it with the Multicast Transformation.

让我们从SSIS工具箱中添加一个Excel文件目标,并将其与多播转换一起加入。

Double click on Excel destination to configure it. In the Excel Destination Editor, click on New and specify the file path and name.

双击Excel目标进行配置。 在Excel目标编辑器中,单击“新建”,然后指定文件路径和名称。

Click Ok, and it goes to excel destination editor. Click on New to create the required columns in the excel sheet.

单击确定,然后转到excel目标编辑器。 单击新建以在excel表中创建所需的列。

Click Ok, and you get the syntax error message.

单击确定,您会收到语法错误消息。

Remove the quotes, and you can create the excel sheet with the required columns.

删除引号,您可以使用所需的列创建Excel工作表。

Click OK and go to Mapping to review mapping between source data and destination excel sheet.

单击“确定”,然后转到“映射”以查看源数据和目标Excel工作表之间的映射。

Click Ok, and we are ready with the Excel destination configuration.

单击确定,我们就可以使用Excel目标配置了。

添加一个SQL Server目标 (Add an SQL Server Destination)

We require a SQL Server destination to get a copy of the source data. We can use OLE DB destination or SQL Server destination for this.

我们需要一个SQL Server目标来获取源数据的副本。 我们可以为此使用OLE DB目标或SQL Server目标。

Drag an OLE DB destination and join with SSIS Multicast Transformation.

拖动OLE DB目标并加入SSIS多播转换。

Double click on this SQL Server Destination to configure it. It opens the SQL Destination Editor, and we can see the existing connection WideWorldImporters in this. Let’s use the same connection for the destination as well.

双击此SQL Server目标进行配置。 它将打开“ SQL Destination Editor”,我们可以在其中看到现有的连接WideWorldImporters。 让我们对目标也使用相同的连接。

We want to create a new table, therefore, click on the New in front of Use a table or view. It opens the script for the CREATE TABLE statement. Give an appropriate name for the table and click Ok.

我们要创建一个新表,因此,单击“使用表或视图”前面的“新建”。 它打开CREATE TABLE语句的脚本。 为表指定一个适当的名称,然后单击“确定”。

You can see the table name in the screenshot below.

您可以在下面的屏幕截图中看到表格名称。

Verify the mapping between the source data and destination table and click OK.

验证源数据和目标表之间的映射,然后单击“确定”。

Click Ok, and it returns to the Control flow tab of the SSIS package. We configured three destinations as per our requirement.

单击“确定”,它返回到SSIS包的“控制流”选项卡。 我们根据要求配置了三个目的地。

Press F5 or click on the Start button to execute the package. The green tick mark on each component shows the package executed successfully.

按F5或单击“开始”按钮执行程序包。 每个组件上的绿色对勾表示软件包已成功执行。

In the following screenshot, we can verify that SSIS Multicast Transformation sends the same copy of data to each destination. We have source row count 1,111 and each destination row count is 1,111.

在下面的屏幕快照中,我们可以验证SSIS组播转换是否将相同的数据副本发送到每个目标。 我们的源行数为1,111,每个目标行数为1,111。

Let’s verify data in the destination files.

让我们验证目标文件中的数据。

  • Flat File Data

    平面文件数据

  • Excel Sheet Data

    Excel工作表数据

  • SQL Server Data

    SQL Server资料

派生列和SSIS组播转换 (Derived column and SSIS Multicast Transformation)

In the previous example, we use SSIS Multicast Transformation to copy the data from the source to the destination such as flat files, excel sheet and SQL tables. The use case of a multicast operator is that we can apply different transformations, aggregations, calculations on logical copies of data.

在前面的示例中,我们使用SSIS组播转换将数据从源复制到目标,例如平面文件,excel工作表和SQL表。 多播运算符的用例是,我们可以对数据的逻辑副本应用不同的转换,聚合和计算。

Suppose we want a new derived column in the SQL Server destination. We do not want derived columns in other destinations.

假设我们要在SQL Server目标中添加一个新的派生列。 我们不希望在其他目标中派生列。

Drag a derived column from the SSIS Toolbox.

从SSIS工具箱中拖动派生的列。

We want to add a new column LoginID, and it should be the reverse of the PreferredName column. In the expression, we use the SQL REVERSE string function.

我们要添加一个新列LoginID,它应该与PreferredName列相反。 在表达式中,我们使用SQL REVERSE字符串函数。

In the SQL Server Destination, create a new table that contains new column Loginname. Drag the green arrow from the derived column to the SQL Server destination.

在SQL Server目标中,创建一个包含新列Loginname的新表。 将绿色箭头从派生列拖到SQL Server目标。

Execute the package, and it shows successful.

执行该程序包,它显示成功。

Let’s check the SQL Server Destination table and see the data in the new column. You can see that the LoginID column contains data reverse to data in the PreferredName column.

让我们检查SQL Server Destination表,并在新列中查看数据。 您可以看到LoginID列包含的数据与PreferredName列中的数据相反。

SELECT [PreferredName], [LoginID]
FROM [WideWorldImporters].[dbo].[SQLDerivedTable];

结论 (Conclusion)

In this article, we explored the SSIS Multicast Transformation to copy the source data into multiple destinations such as flat files, excel files and the SQL Server tables. Try exploring this SSIS component to perform tasks efficiently without any complicated programming code.

在本文中,我们探索了SSIS组播转换,将源数据复制到多个目标中,例如平面文件,excel文件和SQL Server表。 尝试探索此SSIS组件以有效执行任务,而无需任何复杂的编程代码。

翻译自: https://www.sqlshack.com/ssis-multicast-transformation-overview/

ssis 列转换

ssis 列转换_SSIS组播转换概述相关推荐

  1. 查看ssis执行日志_SSIS包日志记录概述

    查看ssis执行日志 This article gives an overview of the different methods of SQL Server SSIS Package Loggin ...

  2. ssis 列转换_SSIS包中的行采样转换和百分比采样转换

    ssis 列转换 This article explores Row Sampling Transformations in SSIS and Percentage Sampling Transfor ...

  3. ssis合并连接链接键_在SSIS包中使用合并联接转换

    ssis合并连接链接键 This article explores the Merge Join Transformation in SSIS packages. 本文探讨了SSIS包中的合并联接转换 ...

  4. 10mbps 局域网组播_无线局域网Apple Bonjour部署指南

    当适合于对支持的组播应用例如Apple的Bonjour协议,本文在运行原理和配置提供信息为Cisco Unified无线LAN解决方案.查询和宣布特定服务的此协议enable (event) Appl ...

  5. IP组播基础(一)点到多点应用特点、组播基本架构、组播IP、MAC地址结构组成

    文章目录 前言 点到多点应用的发展与部署 传统点到点应用 点到多点应用 用单播方式部署点到多点应用 用广播的方式部署点到多点网络 组播方式部署点到多点应用 组播基本概述 组播基本架构 组播源到路由器 ...

  6. ssis 列转换_SSIS中的术语提取转换

    ssis 列转换 This article explores the Term extraction transformation in SSIS and its usage scenario. 本文 ...

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

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

  8. ssis 列转换_将SSIS包转换为Biml脚本

    ssis 列转换 In our previous article, Getting started with Biml, we have explained what Biml is, what ar ...

  9. 【博客546】组播IP地址与组播MAC地址的联系与转换

    组播IP地址与组播MAC地址的联系与转换 先直观感受一下ipv4的转换 ip多播地址: 对应mac多播地址: ipv4,ipv6各种情况 ip组播地址 mac组播地址

最新文章

  1. 百度携手同济大学,瞄准AI、智慧交通等核心科技领域攻关
  2. 解析列表中的数据python_将html数据解析成python列表进行操作
  3. 利用Visual Studio 2005的自动化测试工具来做数据导入
  4. python 类的功能,字符串字节,嵌套等相关学习总结
  5. 美国华尔街拥抱区块链是最大的威胁
  6. 71. Simplify Path
  7. c#异步文件传输功能
  8. 软件评测师教程——软件测试概论
  9. 2022java面试总结
  10. Scratch少儿编程
  11. 利用python做一个超简单的抽签器
  12. 使用ant design遍历多选组件时,选择一个,所有便利的选择器都进行了选择。
  13. win10 1050Ti 笔记本配置 TensorFlow-gpu 过程(多图超详细)
  14. leetcode Revert Binary Tree
  15. 跟小博老师一起学JSP ——通信作用域
  16. 2022-12-30:某天小美进入了一个迷宫探险,根据地图所示,这个迷宫里有无数个房间 序号分别为1、2、3、...入口房间的序号为1 任意序号为正整数x的房间,都与序号 2*x 和 2*x + 1
  17. 令人十分期待的ECShopX BBC商城开放终身免费商用
  18. 已知两点坐标求直线的一般表达式
  19. 【Ian Goodfellow课件】卷积网络
  20. wininet,winhttp,xmlhttprequest,各版本区别 《转》

热门文章

  1. SSM整合 mybatis多条件查询与分页
  2. 从0开始学Python,0基础小白
  3. HDU 4714 Tree2cycle:贪心
  4. 视频基础知识:浅谈视频会议中H.264编码标准的技术发展
  5. ubuntu 下安装配置LAMP
  6. WPF后台自定义文字带背景的选择状态按钮
  7. 我喜欢的歌-FOREVER
  8. LeetCode(561)——数组拆分 I(JavaScript)
  9. 如何优雅的起个变量名?
  10. 移动开发—详解flex布局之携程网首页案例制作