ssis配置文件优先级

This article explores the SSIS Precedence Constraints, along with examples and scenarios.

本文探讨了SSIS优先约束,以及示例和方案。

介绍 (Introduction)

Microsoft SQL Server provides integration services for building SSIS packages to design complex solutions, workflows, data migration, and transformations. Once you launch Visual Studio for an SSIS package, you can see the following components:

Microsoft SQL Server提供了用于构建SSIS包的集成服务,以设计复杂的解决方案,工作流,数据迁移和转换。 为SSIS包启动Visual Studio之后,您可以看到以下组件:

  • Control flow: We define the task in the control flow, such as data flow task, Execute SQL task, FTP task 控制流:我们在控制流中定义任务,例如数据流任务,执行SQL任务,FTP任务
  • Data flow: Data flow defines the source and destination data flow, and we define transformation as well in this tab 数据流:数据流定义了源数据流和目标数据流,我们也在此选项卡中定义了转换
  • Parameters: We can manage SSIS variables using this tab 参数:我们可以使用此选项卡管理SSIS变量
  • Event handlers: It allows defining the event-handling mechanism in the SSIS package事件处理程序:它允许在SSIS包中定义事件处理机制
  • Package explorers: Here, we can explore the SSIS package connections, log providers, variables and parameters 包浏览器:在这里,我们可以浏览SSIS包连接,日志提供程序,变量和参数

SSIS优先约束概述 (Overview of SSIS Precedence Constraints)

In the control flow, we can define multiple workflows, tasks in a single SSIS package. We do not want all the tasks to execute at the same time. Control flow also allows defining the order in which the task will run.

在控制流中,我们可以在单个SSIS包中定义多个工作流和任务。 我们不希望所有任务都同时执行。 控制流还允许定义任务运行的顺序。

Let’s add two execute SQL tasks in the control flow area and configure them to execute the T-SQL statements.

让我们在控制流区域中添加两个执行SQL任务,并将它们配置为执行T-SQL语句。

Note: You can refer to SSIS articles for understanding SSIS configurations.

注意:您可以参考SSIS文章以了解SSIS配置。

I require executing the tasks with the following conditions:

我需要在以下条件下执行任务:

  • Start package execution with SQL task 1 使用SQL任务1开始执行程序包
  • If the SQL task 1 fails, then execute task 2 如果SQL任务1失败,则执行任务2

If we execute the package without any additional configuration, it executes both the tasks in parallel:

如果我们在没有任何其他配置的情况下执行该程序包,它将并行执行两个任务:

We use SSIS precedence constraints to define the program flow from one task to another. We can see a green color arrow in the following image that defines precedence constraints:

我们使用SSIS优先级约束来定义从一个任务到另一个任务的程序流。 我们可以在下图中看到一个绿色箭头,该箭头定义了优先级约束:

We can see green, red, and grey connectors in the Control Flow to link tasks together. The standard and default constraints is a success constraint. Drag an arrow from SQL task 1 and drop it on SQL task 2 to build a success precedence constraint.

我们可以在控制流中看到绿色,红色和灰色的连接器,以将任务链接在一起。 标准约束和默认约束是成功约束。 将箭头从SQL任务1拖放到SQL任务2上以构建成功优先级约束。

In the following image, the SQL task 2 executes if and only if the execution of SQL task 1 is successful:

在下图中,SQL任务2仅在成功执行SQL任务1时执行:

We can change the precedence constraint from success to failure or completion. Right-click on the arrow and choose different precedence, as shown in the following screenshot:

我们可以将优先约束从成功更改为失败或完成。 右键单击箭头,然后选择其他优先级,如以下屏幕截图所示:

Let’s change it to failure and arrow colour changes to Red. It also shows an annotation for failures.

让我们将其更改为失败,箭头颜色更改为红色。 它还显示了故障注释。

In this scenario, the package executes in the following manner:

在这种情况下,程序包以以下方式执行:

  • Start package execution with SQL task 1 使用SQL任务1开始执行程序包
  • If the SQL task 1 fails, then only execute task 2 如果SQL任务1失败,则仅执行任务2

In the following screenshot, we can see that SSIS does not execute the task 2 because task 1 status is successful:

在下面的屏幕快照中,我们可以看到SSIS没有执行任务2,因为任务1的状态为成功:

Modify the package so that SQL task 1 fails and execute it again. Now, it executes the task 2 as defined in the failure condition of SQL task 1:

修改程序包,以使SQL任务1失败并再次执行。 现在,它执行SQL任务1的失败条件中定义的任务2:

Another SSIS precedence constraint is completion. Sometimes, we want to execute another task even first task execution status is a success or fail:

SSIS的另一个优先约束是完成。 有时,我们希望执行另一个任务,即使第一个任务的执行状态是成功还是失败:

In the following screenshot, executes SQL task 2 is successful despite task 1 failure:

在以下屏幕截图中,尽管任务1失败,执行SQL任务2仍成功:

It also executes task 2 if SQL task 1 is successful:

如果SQL任务1成功,它也会执行任务2:

We have explored the basics of SSIS Precedence Constraints in the SSIS package. Let’s have a summary theoretically and explore it further.

我们已经在SSIS包中探索了SSIS优先约束的基础。 让我们从理论上进行总结,并进一步进行探索。

As highlighted above, we have the following precedence constraints in SSIS.

如上所述,SSIS中具有以下优先约束。

First, let me give brief information about the components involved in SSIS precedence constraints:

首先,让我简要介绍一下SSIS优先级约束所涉及的组件:

  • Precedence Executable: It is the source from where we define the precedence constraints 优先级可执行文件:它是定义优先级约束的来源
  • Constrained Executable: It is the destination task, and its execution depends on the defined precedence constraints and outcome of precedence executable 约束可执行文件:这是目标任务,其执行取决于定义的优先级约束和优先级可执行文件的结果

Double-click on precedence, and it opens the precedence constraints editor:

双击优先级,它将打开优先级约束编辑器:

In this editor, we have the following SSIS Precedence Constraints options:

在此编辑器中,我们具有以下SSIS优先约束选项:

1.约束 (1. Constraints)

Here, we define the precedence constraints as defined above. We have the following precedence constraints options available.

在这里,我们定义了上面定义的优先约束。 我们提供以下优先顺序约束选项。

成功 (Success)

In this constraint, precedence executable must execute successfully so that the constrained executables can execute. The color of success precedence is green.

在这种约束下,优先级可执行文件必须成功执行,以便受约束的可执行文件可以执行。 成功优先级的颜色为绿色。

失败 (Failure)

In this constraint, precedence executable must fail so that the constrained executable can execute. Its color is red.

在这种约束下,优先级可执行文件必须失败,以便受约束的可执行文件可以执行。 它的颜色是红色。

完成时间 (Completion)

It runs the constrained executable regardless of the state of precedence executable task. The color for completion precedence constraint is blue.

无论优先级可执行任务的状态如何,它都会运行受约束的可执行文件。 完成优先级约束的颜色为蓝色。

We can define multiple SSIS precedence constraints for a single task in the SSIS package. In the following screenshot, all three precedence constraints with executing SQL task 1:

我们可以在SSIS包中为单个任务定义多个SSIS优先约束。 在以下屏幕截图中,执行SQL任务1的所有三个优先约束:

2.表达 (2. Expression)

If we choose expressions in SSIS precedence constraints, it evaluates the expression and if the expression is true, then the constrained executable runs.

如果我们选择SSIS优先级约束中的表达式,它将评估该表达式,如果该表达式为true,则受约束的可执行文件将运行。

For example, in the following screenshot, we defined an expression for checking the weekday as per the following example:

例如,在以下屏幕截图中,我们根据以下示例定义了一个用于检查工作日的表达式:

DATEPART(“weekday”,GETDATE()) == 1

DATEPART(“工作日”,GETDATE())== 1

Click on Test, and it evaluates the expression:

点击Test ,它计算表达式:

Click OK, and it changes the expression symbol fx as shown below:

单击OK ,它将更改表达式符号fx,如下所示:

It runs the constrained executable if the evaluated expression is true:

如果评估表达式为真,它将运行受约束的可执行文件:

If the expression returns false condition, it doesn’t execute the constrained executable:

如果表达式返回错误条件,则不执行受约束的可执行文件:

3.表达式和约束 (3. Expressions and Constraint)

In this mode, the SSIS package evaluates both precedence constraint and expression. The output of both must be true so that constrained executable can run.

在这种模式下,SSIS包同时评估优先级约束和表达式。 两者的输出都必须为true,这样受约束的可执行文件才能运行。

For example, open the SSIS precedence constraint editor and change the options as follows:

例如,打开SSIS优先级约束编辑器并按如下所示更改选项:

  • Evaluation operation: Expression and Constraint评估操作:表达和约束
  • Value: Success价值:成功
  • Expression: DATEPART(“weekday”,GETDATE()) == 2
  • 表达式: DATEPART(“平日”,GETDATE())== 2

Click OK, and it looks as per the following screenshot:

单击“ 确定” ,其外观如下图所示:

Execute the package, and we see that it did not run the constrained executable. Upon investigation, we find the following facts:

执行该程序包,我们看到它没有运行受约束的可执行文件。 经调查,我们发现以下事实:

  • Precedence constraint returns true because execute SQL task 1 is a success 优先约束返回true,因为执行SQL任务1成功
  • The expression does not meet the criteria and returns a false value 表达式不符合条件,返回错误值
  • The combination of precedence constraints and expressions return false, and it does not execute the constrained executable 优先级约束和表达式的组合返回false,并且不执行受约束的可执行文件

Let’s change the expression so that it returns true, and it executes the constrained executable.

让我们更改表达式,使其返回true,然后执行受约束的可执行文件。

  • Precedence constraint returns true because execute SQL task 1 is a success 优先约束返回true,因为执行SQL任务1成功
  • Expression meets the criteria and returns a true value 表达式符合条件并返回真实值
  • The combination of precedence constraints and expressions return true, and it executes the constrained executable as well 优先约束和表达式的组合返回true,并且它也执行受约束的可执行文件

Similarly, we can change it to failure precedence constraint and expression:

同样,我们可以将其更改为故障优先约束和表达式:

4.表达式或约束 (4. Expressions or Constraint)

In this option, at least one of the SSIS precedence constraint or expression should be true. Looking at the above example, change the SSIS precedence constraints editor to reflect this change:

在此选项中,SSIS优先级约束或表达式中的至少一个应为true。 查看上面的示例,更改SSIS优先级约束编辑器以反映此更改:

Execute the SSIS package and note the difference:

执行SSIS包并注意区别:

  • SSIS Precedence constraint returns true because execute SQL task 1 is success SSIS优先约束返回true,因为执行SQL任务1成功
  • The expression does not meet the criteria and returns a false value 表达式不符合条件,返回错误值
  • true value. It executes the constrained executable as well 真实值。 它还执行受约束的可执行文件

多个SSIS优先约束 (Multiple SSIS Precedence Constraints)

Let’s make things more complicated. Add one more execute SQL task and connect it to SQL task 2:

让事情变得更复杂。 再添加一个执行SQL任务,并将其连接到SQL任务2:

Now execute SQL task contains two precedences defined on it:

现在,执行SQL任务包含两个在其上定义的优先级:

  • Precedence constraint from SQL task 1 SQL任务1的优先约束
  • Precedence constraint from SQL task 3 SQL任务3的优先约束

Intentionally, I have made a syntax error in SQL task 3 so that it should fail. Execute the SSIS package, and You see the following component status.

我故意在SQL任务3中犯了语法错误,因此它应该失败。 执行SSIS包,您将看到以下组件状态。

  • Execute SQL task 1 status is a success 执行SQL任务1状态为成功
  • Execute SQL task 3 status is fail 执行SQL任务3状态失败

We cannot see the execution of SQL task 2 while it should execute because of success precedence constraint from task 1:

由于任务1的成功优先级限制,我们无法看到应执行SQL任务2的执行。

However, it did not execute the constrained executable. Let’s investigate the reason for it. Open the precedence constraint editor, and you can see the following property for multiple constraints:

但是,它没有执行受约束的可执行文件。 让我们调查原因。 打开优先约束编辑器,您可以看到多个约束的以下属性:

If we have multiple constraints for a task, this property controls the behavior for the constrained executable execution.

如果我们对一个任务有多个约束,则此属性控制受约束的可执行执行的行为。

By default, all the constraints must evaluate to True. Due to this, we did not see the execution of SQL task 2 because one of the precedence constraints is false (failure of SQL task 3).

默认情况下,所有约束必须评估为True。 因此,由于优先约束之一为假(SQL任务3失败),因此我们看不到SQL任务2的执行。

Let’s change the value of multiple constraint property-Logical OR– One constraint must evaluate to True:

让我们更改多约束属性的值- 逻辑或 -一个约束必须求值为True:

Click OK, and you can note the changes in SSIS precedence constraints lines. It changes lines from solid to dotted lines:

单击“ 确定” ,您可以注意到SSIS优先约束行中的更改。 它将线条从实线更改为虚线:

Execute the SSIS package, and we can see the following:

执行SSIS包,我们可以看到以下内容:

  • Execute SQL task 1 status is a success 执行SQL任务1状态为成功
  • Execute SQL task 3 status is fail 执行SQL任务3状态失败
  • Logical OR of these two precedence constraints returns true, and it executes SQL task 2 这两个优先约束的逻辑或返回true,并执行SQL任务2

结论 (Conclusion)

SSIS Precedence constraints are a useful feature of the SSIS package for defining workflow and task execution sequences. We can use it for validation checks, error handling and build a complete solution as per our requirement.

SSIS优先级约束是SSIS包的有用功能,用于定义工作流和任务执行顺序。 我们可以根据需要将其用于验证检查,错误处理并构建完整的解决方案。

翻译自: https://www.sqlshack.com/overview-of-ssis-precedence-constraints/

ssis配置文件优先级

ssis配置文件优先级_SSIS优先约束概述相关推荐

  1. spring配置文件_SpringBoot入门建站全系列(二十三)配置文件优先级及自定义配置文件...

    SpringBoot入门建站全系列(二十三)配置文件优先级及自定义配置文件 一.概述 Spring Boot允许多种配置来源,官网是这样说的: Spring Boot使用一种非常特殊的Property ...

  2. springboot加载配置文件优先级

    1.1 springboot启动会扫描一下位置的application.properties或者application.yml作为默认的配置文件 工程根目录:./config/ 工程根目录:./ cl ...

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

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

  4. 无法创建ssis数据流任务_SSIS中的数据分析任务概述

    无法创建ssis数据流任务 The Data Profiling task in SSIS is an important task that can be used to assess the qu ...

  5. ssis 计划任务_SSIS FTP任务概述

    ssis 计划任务 In this article, we will explain the File Transfer Protocol (FTP), and we will give an ove ...

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

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

  7. ssis 列转换_SSIS组播转换概述

    ssis 列转换 This article explores the SSIS Multicast Transformation for creating different logical copi ...

  8. ssis 表达式任务_SSIS表达式任务与将变量作为表达式求值

    ssis 表达式任务 In this article, I will first give an introduction about SSIS expressions, then I will de ...

  9. ansible 配置文件优先级

    优先级如下: 1.首先找执行ansible命令的当前目录中,是否有 ansible.cfg文件 ./ansible.cfg 2.如果找不到,再 找 当前用户的家目录下是否有 .ansible.cfg ...

最新文章

  1. HCTL-2020正交码读写芯片
  2. 【iOS数据持久化】Plist使用
  3. hive like 模糊匹配
  4. 编程体系结构(09):分布式系统架构
  5. @RequestParam @RequestBody @PathVariable 等参数绑定
  6. 美国自动驾驶研发国家队NASA入局,还提供了航天跑道做测试
  7. 循环双链表的手动构建总结
  8. placeholder在某些浏览器下不垂直居中问题
  9. python面试48题及答案_python常见面试题
  10. 转:.Net 中AxShockwaveFlash的解析
  11. 1085 Perfect Sequence(25 分)
  12. 自然语言处理NLP星空智能对话机器人系列:理解语言的 Transformer 模型-子词分词器
  13. android模拟器设置静态ip,安卓模拟器多开挂手游改IP防封号技术讲解
  14. IT桔子沙龙之本地生活服务O2O探路者笔记整理
  15. 使用STAR构建参考基因组并比对
  16. 偏见:人工智能辅助决策的隐患
  17. Android6.0权限的处理
  18. smbrun - smbd和外部程序间的接口程序。
  19. 主板bios密码清除案例
  20. Linux下终端分屏利器tmux

热门文章

  1. mysql时区代码_mysql时区设置为东八区
  2. jQuery多选列表框插件Multiselect
  3. Excel中复杂跨行跨列数据
  4. IntelliJ IDEA实时模板变量
  5. 前端性能优化(一)-- 文件的压缩与合并
  6. ubuntu程序安装方法
  7. Windows phone 8 学习笔记(7) 设备
  8. su root 后还是不能使用useradd ,useradd 等命令
  9. XML Schema 配置文件自动生成c#类设计案例子
  10. (实用工具分享)网页元素截图工具