ssis组件

SSIS Script component is a prominent strength of SQL Server Integration Services since it allows developers to implement any complex logic and utilize libraries from the powerful .NET framework or third-parties.

SSIS脚本组件是SQL Server集成服务的突出优势,因为它允许开发人员实现任何复杂的逻辑并利用功能强大的.NET框架或第三方提供的库。

In this article, we will give an overview of SSIS Script component, and illustrate the benefits of using it. In addition, we will answer some of the most common questions asked concerning writing scripts in SSIS, such as the difference between a derived column transformation and a Script component.

在本文中,我们将概述SSIS脚本组件,并说明使用它的好处。 另外,我们将回答一些有关在SSIS中编写脚本的常见问题,例如派生列转换和Script组件之间的区别。

SSIS Script component can be used in three ways:

SSIS脚本组件可以三种方式使用:

  1. As a source component 作为源组件
  2. As a destination component 作为目标组件
  3. As a transformation component 作为转换组件

When adding a Script component to the data flow task, you will be asked how the script will be used, as shown in the image below:

将脚本组件添加到数据流任务时,将询问您如何使用脚本,如下图所示:

SSIS脚本组件编辑器 (SSIS Script component editor)

Before describing each approach, we will illustrate the options that can be configured in the SSIS script component editor. If you open the SSIS Script component editor, you will see four tabs:

在介绍每种方法之前,我们将说明可以在SSIS脚本组件编辑器中配置的选项。 如果打开SSIS脚本组件编辑器,将看到四个选项卡:

  • Script: Here, you can open the script editor where you can write your script, select the script programming language (C# or VB.NET) and select the SSIS variables you need within the script (for read or write purposes) 脚本:在这里,您可以打开脚本编辑器,在其中编写脚本,选择脚本编程语言(C#或VB.NET),然后在脚本中选择所需的SSIS变量(用于读取或写入)
  • Input Columns: Here, you can select the input columns for use within the script 输入列:在这里,您可以选择脚本中要使用的输入列
  • Inputs and Outputs: Here, you can configure the outputs generated by the script (number of outputs, type of each output, output columns, etc.) 输入和输出:在这里,您可以配置脚本生成的输出(输出数量,每个输出的类型,输出列等)
  • Connection Managers: Here, you can select the connection managers for use within the script 连接管理器:在这里,您可以选择要在脚本中使用的连接管理器

Note, that when using the SSIS script component as a source, there are no input columns to select. In addition, when using this component as a destination, no output configuration is needed.

请注意,使用SSIS脚本组件作为源时,没有输入列可供选择。 另外,使用此组件作为目标时,不需要输出配置。

Additional information can be found in the following documentation: Configuring the Script Component in the Script Component Editor.

在以下文档中可以找到更多信息: 在脚本组件编辑器中配置脚本组件 。

SSIS脚本组件作为源 (SSIS Script component as source)

The first way to use a script component is as a source. This approach is useful when reading from a data source that doesn’t have its own source component (Flat File, Excel, OLE DB, etc.,) such as when reading JSON data from a Web API or reading an unstructured Flat File that can’t be handled using a Flat File Connection Manager.

使用脚本组件的第一种方法是作为源。 当从没有自己的源组件(平面文件,Excel,OLE DB等)的数据源中读取数据时,例如从Web API读取JSON数据或读取可以不能使用平面文件连接管理器来处理。

Refer to the following links for more information and some examples:

请参阅以下链接以获取更多信息和一些示例:

  • Creating a Source with the Script Component 使用脚本组件创建源
  • How to create a SSIS package to ETL JSON from Python REST API request into MSSQL server? 如何创建从Python REST API请求到MSSQL服务器的ETL JSON的SSIS包?
  • How to connect TIBO EMS using SSIS 如何使用SSIS连接TIBO EMS
  • SSIS – USING A SCRIPT COMPONENT AS A SOURCE SSIS –使用脚本部件作为源
  • Using REST API in SSIS to Extract Top 100 User Tweets 在SSIS中使用REST API提取前100条用户推文

SSIS脚本组件作为目标 (SSIS Script component as destination)

The second way to use an SSIS Script component is as a destination. This approach is useful when exporting the data into a file that is not supported by other destination components, or for applying some processing without the need for a destination component.

使用SSIS脚本组件的第二种方法是作为目标。 当将数据导出到其他目标组件不支持的文件中,或者不需要目标组件进行某些处理时,此方法很有用。

Refer to the following links for additional information:

请参阅以下链接以获取更多信息:

  • Creating a Destination with the Script Component 使用脚本组件创建目标
  • SSIS XML Destination SSIS XML目标

SSIS脚本组件转换 (SSIS Script component transformation)

The third and most popular way to use a script component is for transformations. In this approach, the script component reads input values from the data flow and generates outputs. There are two types of outputs that can be generated:

使用脚本组件的第三种也是最流行的方法是进行转换。 在这种方法中,脚本组件从数据流中读取输入值并生成输出。 可以生成两种类型的输出:

  • Synchronous output 同步输出
  • Asynchronous output 异步输出

In this section, we will briefly describe these two output types, and you can refer to the following link for more information: Understanding Synchronous and Asynchronous Transformations.

在本节中,我们将简要描述这两种输出类型,并且您可以参考以下链接以获取更多信息: 了解同步和异步转换 。

同步输出 (Synchronous output)

With this output type, there is an output row for each input row. All output columns defined in the output buffer are added to the input row. As shown in the image below, in the Inputs and Outputs tab page, you must select the synchronous input property for the output buffer created:

使用此输出类型,每个输入行都有一个输出行。 将输出缓冲区中定义的所有输出列添加到输入行。 如下图所示,在“输入和输出”选项卡页面中,必须为创建的输出缓冲区选择同步输入属性:

When performing a synchronous transformation, all input and output columns are accessed using the Row class. As an example:

执行同步转换时,使用Row类访问所有输入和输出列。 举个例子:

Row.outColumn = Row.InColumn + “_1”;

Row.outColumn = Row.InColumn +“ _1”;

For more information, refer to the following official documentation:

有关更多信息,请参考以下官方文档:

  • Creating a Synchronous Transformation with the Script Component 使用脚本组件创建同步转换

异步转换 (Asynchronous transformation)

With this transformation type, each input row may have 0 or multiple output buffers. You can set the output type as asynchronous by setting the SynchronousInput property to None:

使用此转换类型,每个输入行可以具有0个或多个输出缓冲区。 您可以通过将SynchronousInput属性设置为None来将输出类型设置为异步:

You must use the output buffer wrapper class to add an output row and to assign values to columns. As an example, if the output buffer name is “Output1,” then you must use the following code:

您必须使用输出缓冲区包装器类来添加输出行并将值分配给列。 例如,如果输出缓冲区名称为“ Output1”,则必须使用以下代码:

Output1Buffer.AddRow();
Output1Buffer.outColumn = “abc”;

Output1Buffer.AddRow();
Output1Buffer.outColumn =“ abc”;

For more information, refer to the following official documentation:

有关更多信息,请参考以下官方文档:

  • Creating an Asynchronous Transformation with the Script Component 使用脚本组件创建异步转换

单/多输出 (Single/multiple outputs)

From the Inputs and Outputs tab, you can add multiple output buffers, and you can configure each one as synchronous or asynchronous based on the logic you want to implement.

在“输入和输出”选项卡上,可以添加多个输出缓冲区,并且可以根据要实现的逻辑将每个缓冲区配置为同步或异步。

派生列与脚本组件 (Derived Column vs. Script Component)

One of the most common questions asked is when to use a derived column transformation or a script component. A derived column is used to apply simple transformations using SSIS expressions and doesn’t require programming language knowledge. An SSIS Script component is more advanced and is used to implement more complex logic than the derived column.

提出的最常见问题之一是何时使用派生列转换或脚本组件。 派生列用于使用SSIS表达式应用简单的转换,并且不需要编程语言知识。 SSIS脚本组件比派生列更高级,用于实现更复杂的逻辑。

Also, the script component can use .NET Framework libraries and functions, as well as third-party assemblies, which is not possible in derived columns.

此外,脚本组件可以使用.NET Framework库和函数以及第三方程序集,而这在派生列中是不可能的。

More details about the differences between the SSIS script component and derived columns are mentioned in the following article:

以下文章中提到了有关SSIS脚本组件和派生列之间差异的更多详细信息:

  • SSIS Script component vs derived column SSIS脚本组件与派生列

If you are new to SSIS, refer to the following link to learn more about SSIS Derived column transformation:

如果您不熟悉SSIS,请参考以下链接以了解有关SSIS派生列转换的更多信息:

  • SSIS Derived Columns with Multiple Expressions vs Multiple Transformations 具有多个表达式与多个转换的SSIS派生列

调用目标已引发异常 (Exception has been thrown by the target of an invocation)

One of the most common errors related to writing scripts in SSIS is that the Script component or Script Task has encountered an error at runtime but the exception message does not provide further information: “Exception has been thrown by the target of an invocation”.

与在SSIS中编写脚本有关的最常见错误之一是,脚本组件或脚本任务在运行时遇到错误,但异常消息未提供进一步的信息: “调用的目标已引发异常”

This is a generic error message that is shown when a script fails. To retrieve the original error message, you have to implement a try/catch logic and use ComponentMetadata class to fire the real error message:

这是脚本失败时显示的一般错误消息。 要检索原始错误消息,您必须实现一个try / catch逻辑并使用ComponentMetadata类来触发实际的错误消息:

try{//...write your code hereDts.TaskResult = (int)ScriptResult.Success;}catch(Exception ex){ComponentMetaData.FireError(0,"An error occured", ex.Message,String.Empty, 0);}

Additional information can be found on: SSIS – Script Task error: Exception has been thrown by the target of an invocation. (just note that in a script task, DTS namespace is used instead of ComponentMetadata).

可以在以下位置找到其他信息: SSIS –脚本任务错误:调用的目标引发了异常。 (请注意,在脚本任务中,使用DTS命名空间而不是ComponentMetadata)

结论 (Conclusion)

In this article, we have provided an overview of the SSIS script component, and showed how it can be used within the data flow task. In addition, we briefly described the differences between Script and derived columns. Finally, we showed how to read the error messages thrown in runtime.

在本文中,我们提供了SSIS脚本组件的概述,并展示了如何在数据流任务中使用它。 此外,我们简要描述了Script列和派生列之间的区别。 最后,我们展示了如何读取运行时引发的错误消息。

翻译自: https://www.sqlshack.com/ssis-script-component-overview/

ssis组件

ssis组件_SSIS脚本组件概述相关推荐

  1. ssis 派生列_SSIS脚本组件与派生列

    ssis 派生列 介绍 (Introduction) In this article, we will show how to convert dates from dd/mm/yyyy to mm/ ...

  2. SSIS 通过添加脚本组件 自定义转换数据

    问题:从mysql导入到sql的汉字都是乱码或者干脆导入不成功,报"截断字符串"错误,错在mysql当时建立的都是使用的默认编码latin1;搞不明白,又不是瑞典人,你用这个干毛. ...

  3. unity获取脚本组件_Unity脚本组件

    Unity页面有层次视图,Project工程视图,Scene场景视图,检视窗口; 脚本组件一般都显示在检视窗口中; 检视窗口: 可以显示游戏场景中当前旋转对象的详细信息,以及游戏整体的属性设置;包括对 ...

  4. 如何在SSIS的脚本组件中访问变量

    原文:如何在SSIS的脚本组件中访问变量 这是一个小问题,我们在SSIS的设计中很多地方都会用到变量,我习惯性地将"变量"和"表达式"称为SSIS的灵魂,虽然不 ...

  5. ssis 角本组件更新数据_使用SSIS脚本组件作为数据源

    ssis 角本组件更新数据 介绍 (Introduction) SSIS Script component is one data transformation tasks in SQL Server ...

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

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

  7. SSIS中循环遍历组件[Foreach Loop Container]

    背景 每月给业务部门提取数据,每个分公司都要提取一般,先跑SQL,再粘贴到Excel中,然后发邮件给相关的人员.费时费力,还容易粘贴错位.因此,需要通过一个程序完成这些步骤.我首先想到的是通过SSIS ...

  8. COM(Componet Object Model_组件对象模型)技术概述

    COM(Componet Object Model_组件对象模型)技术概述 转载FDCFDMin 最后发布于2018-09-07 20:33:55 阅读数 2065 收藏 https://blog.c ...

  9. Kettle8.2脚本组件之javascript脚本

    Kettle8.2脚本组件之javascript脚本 一.相关说明 二.设计转换 三.转换配置 四.运行转换 五.结果查看 一.相关说明 脚本组件说明: 脚本就是直接通过程序代码完成一些复杂的操作. ...

最新文章

  1. python面试常见问题-Python面试中最常见的25个问题
  2. SCCM 2012 R2---配置客户端发现方法和边界组
  3. ISR:中断服务程序需要满足的要求
  4. html相同数据合并单元格合并单元格,基于JQuery实现相同内容合并单元格的代码...
  5. Oracle一定有sqlplus吗,oracle sqlplus执行sql文件
  6. 微软拥抱开源,Win10为啥要引入真Linux4.X内核?
  7. python基础小白题2
  8. 关于c++中运算符的总结
  9. esp8266 继电器接线图_esp8266控制继电器问题(通电瞬间继电器吸合断开一次)
  10. ajax的url怎么将后缀补上_球形门锁怎么拆装?球形门锁安装的方法都包括哪些?
  11. js原生attachEvent与addEventListener的用法
  12. adb驱动和adb工具官方下载链接
  13. 用Python+PIL将多个jpg图像批量合并成一个pdf文件
  14. URL rewrite
  15. 算法导论第十二章总结以及课后题答案
  16. PMP第二轮复习:整本书内容融会贯通
  17. flask 视频流直播
  18. IEEE2019论文:使用基于特征融合和缩放的具有空间上下文分析的单镜头检测器在无人机图像中检测小物体
  19. 电脑无法显示移动硬盘文件内容的解决方法
  20. 何以解忧,唯有暴富,2019再见

热门文章

  1. html上传图片至数据库,Django 图片上传到数据库 并调用显示
  2. python退出函数_【转】python 退出程序的方式
  3. python错了能改写吗_python 日常错误
  4. python编程技术总结_大数据技术学习之Spark技术总结
  5. 设计模式(Python)-观察者模式
  6. ISCC2018(misc)
  7. concurrency runtime学习笔记之二:并行
  8. 变量提升、作用域this实战(真题:看代码输出)
  9. HTML+CSS制作3D旋转相册
  10. erp软件是什么软件