[英]How to add a column based on the table which the data come from in SSIS?
I have two source tables:我有两个源表:
both have the same columns : "each table have different data this is just an example"两者都有相同的列:“每个表都有不同的数据,这只是一个例子”
ID, START_DATE, END_DATE,
01, 28/02/2021, 04/05/2021
02, 11/10/2021, 09/01/2022
03, 08/01/2022, 03/05/2022
I want to merge them in one table in the destination Database, while maintaining the information of the type of the agreement by adding a columns "AGREEMENT_TYPE" that contain "Ext" or "ABS" based of the source table of the Agreement.我想将它们合并到目标数据库中的一个表中,同时通过基于协议的源表添加包含“Ext”或“ABS”的列“AGREEMENT_TYPE”来维护协议类型的信息。
the destination table will have :目标表将具有:
ID, START_DATE, END_DATE, AGREEMENT_TYPE
01, 28/02/2021, 04/05/2021, ABS
02, 11/10/2021, 09/01/2022, EXT
03, 08/01/2022, 03/05/2022, ABS
I tried merge and Union All and derived columns, but I didn't succeed.我尝试了合并和联合所有以及派生列,但我没有成功。 thank you谢谢你
How about a UNION ALL in your source.你的源中的 UNION ALL 怎么样。
select ID, START_DATE, END_DATE, AGREEMENT_TYPE = 'EXT'
from Ext_Agreements
UNION ALL
select ID, START_DATE, END_DATE, AGREEMENT_TYPE = 'ABS'
from ABS_Agreements
If you want to use SSIS, then...如果你想使用 SSIS,那么...
In data flow.在数据流中。
Create a source based on:根据以下内容创建源:
select ID, START_DATE, END_DATE --, AGREEMENT_TYPE = 'EXT'
from Ext_Agreements
Add a derived column and add:添加派生列并添加:
AgreementType and set (DT_WSTR, 3) "EXT"
Do the same this for ABS (source and der col).对 ABS(源和 der col)执行相同的操作。
Then put them together in a UnionAll.然后将它们放在一个 UnionAll 中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.