1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > ssis组件_SSIS脚本组件概述

ssis组件_SSIS脚本组件概述

时间:2020-10-02 09:51:30

相关推荐

ssis组件_SSIS脚本组件概述

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脚本组件可以三种方式使用:

As a source component 作为源组件 As a destination component 作为目标组件 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 ) and select the SSIS variables you need within the script (for read or write purposes)脚本:在这里,您可以打开脚本编辑器,在其中编写脚本,选择脚本编程语言(C#或),然后在脚本中选择所需的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列和派生列之间的区别。 最后,我们展示了如何读取运行时引发的错误消息。

翻译自: /ssis-script-component-overview/

ssis组件

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。