0

我只是想知道这是否是完成这项任务的正确方法。非常感谢任何其他改进这一点的建议。

我的 SSIS 包上有以下内容。

在此处输入图像描述

  1. 数据流任务并与视图所在的源数据库建立了 OLE DB 连接。
  2. 执行 SQL 任务 - 我正在执行一个带有 INSERT INTO Destination except 的查询(源中已经存在的所有记录。)
  3. 发送邮件任务是发送一封电子邮件。

如何知道数据传输成功?这样我就可以使用发送邮件来指示成功或失败。

如何安排此包以使其自动运行(每周二。)

我已经尝试了下面的建议。请参阅新的数据流任务。

在此处输入图像描述

OLE DB 源 - 指向数据库服务器 1 中的视图 查找从 OLE DB 源获取所有行。(源和查找的行数)匹配。

在查找任务中,我已将错误输出配置为在所有映射列上使用“重定向行”。

在 OLE DB 目标(目标表中,它已经具有来自源的记录子集。因此,配置错误输出以获取不匹配的行以进行插入。

当我执行包时 - 我收到主键约束错误 - 无法插入重复键。

有什么建议么?

4

1 回答 1

1

You will want to double click the connector from the Execute SQL Task to Send Mail Task Currently it's green which indicates it will only take that path on Success. You will want to update the constraint to be on Completion as you don't care if it's Success or Fail.

It sounds like you have your data flow pulling all of the data from your source and writing to a staging table. In your Execute SQL Task, you then use a query to add data into your target table where it doesn't exist.

This can be consolidated into a single Data Flow. Between your OLE DB Source and OLE DB Destination, add a Lookup task. Since you are on 2005, the Lookup behaves a bit differently than 2008+. You will write a query that pulls back the business keys in your target table and then compares that to what is coming from your OLE DB Source. Map those keys in the interface.

You only want the rows that aren't matched so you will need to get the "unmatched records" from the lookup. In 2005, the option for Unmatched output didn't exist so you will need to route the Error output to your OLE DB Destination.

Andy Leonard has a nice little writeup on how to accomplish this: Configuration an SSIS 2005 Lookup Transformation for a Left Outer Join The only difference for your case, is that you don't care about the matched rows. Instead of Ignore Failure, you want to select Redirect Row. Then when you go to connect the Lookup to the OLE DB Destination, you will be presented with two options. The Green Connector is the Matched, Red Connector is the Unmatched rows. Tie the Red path to your Destination

于 2013-08-21T14:41:10.753 回答