如何比较SSIS中的两个表?(SQL 服务器) [英] How to compare two tables in SSIS? (SQL Server)

查看:28
本文介绍了如何比较SSIS中的两个表?(SQL 服务器)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个 SSIS 包,它将比较两个表,然后在另一个表中插入数据.

I am creating an SSIS package that will compare two tables and then insert data in another table.

我应该使用哪种工具?我尝试使用条件拆分",但看起来它只需要一张表作为输入,而不是两张.

Which tool shall I use for that? I tried to use "Conditional Split" but it looks like it only takes one table as input and not two.

这些是我的表格:

TABLE1

身份证
状态

TABLE2

身份证
状态

TABLE3

身份证
状态

我想比较两个表中的 STATUS 字段.如果 TABLE1 中的 Status 为Pending",而 TABLE2 中的 Status 为Open",则在 TABLE3 中插入​​此记录.

I want to compare STATUS field in both tables. If Status in TABLE1 is "Pending" and in TABLE2 is "Open" then insert this record in TABLE3.

推荐答案

我设法通过使用 Execute SQL Task 工具并在其中编写以下查询来做到这一点.

I managed to do it by using Execute SQL Task tool and writing the following query in it.

INSERT INTO TABLE3 (ID, Status) 
SELECT * FROM TABLE1 t1, TABLE2 t2 
WHERE t1.ID = t2.ID and t1.status = 'Pending' and t2.status = 'Open'

这篇关于如何比较SSIS中的两个表?(SQL 服务器)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆