具有批次 ID 的 SSIS 类型 2 scd

发布于 2025-01-09 08:53:39 字数 682 浏览 0 评论 0原文

我想修改标准 SSIS SCD 行为。

EmployeeID 是我的业务密钥,职称、名字、姓氏是类型 2 属性。 我希望 BatchLogID 能够反映更改发生的时间 - 否则它保持不变。

传递到数据流

BatchLogID 作为 int EmployeeID,title,firstname,lastname,BatchLogID,startdate,enddate

源数据

101,Miss,Jane,Smith,101 -- 首次插入

101,Miss,Jane,Smith,102 进程运行

101 ,Jane,Smith 小姐,103 进程运行

101,Miss,Jane,Smith,104 进程运行

101,Mrs, Jane,Brown,105 进程运行 -- 仅当数据发生更改时我才希望目标中的批次号更新

目标数据

101,Miss ,Jane,Smith,101,101,1 jan 2000,null--首次插入

101,Miss,Jane,Smith,105,105,1 jan 2000,5 Jan 2000 -- 当检测到更改时,数据会更新

101,Mrs, Jane,Brown,105,105 jan 2000,null-- 仅当数据更改为 I 时想要更新批次号

有什么想法吗?

I want to modify standard SSIS SCD behavior.

EmployeeID is my business key and title, firstname, lastname are type 2 attributes.
I want BatchLogID to reflect when a change occurred - otherwise it remains unchanged.

BatchLogID is passed to dataflow as an int

EmployeeID,title,firstname,lastname,BatchLogID,startdate,enddate

source data

101,Miss,Jane,Smith,101 -- inserted for first time

101,Miss,Jane,Smith,102 process runs

101,Miss,Jane,Smith,103 process runs

101,Miss,Jane,Smith,104 process runs

101,Mrs, Jane,Brown,105 process runs -- only when data has changed do I want the Batch number in target updated

target data

101,Miss,Jane,Smith,101,101,1 jan 2000,null-- inserted for first time

101,Miss,Jane,Smith,105,105,1 jan 2000,5 Jan 2000 -- as a change is detected the data is updated

101,Mrs, Jane,Brown,105,105 jan 2000,null-- only when data has changed to I want the Batch number updated

any thoughts?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

自由如风 2025-01-16 08:53:39

您可能需要使用以下方法执行增量加载:

  • 查找和派生列
  • 合并连接、条件拆分和派生列
  • 更改数据捕获
  • 临时表(如果 RDBMS 支持)

要了解更多信息:

https://www.c-sharpcorner.com/article/design-the-full-load-and-delta-load-patterns-in-ssis/

You may need to perform delta load using :

  • Lookup and derived column
  • Merge join, Conditional Split and derived column
  • Change Data Capture
  • Temporal tables (if the RDBMS supports that)

To know more :

https://www.c-sharpcorner.com/article/design-the-full-load-and-delta-load-patterns-in-ssis/

蝶…霜飞 2025-01-16 08:53:39

使用了 sql merge 命令 - 必须清洗两次

declare @batchLogID int= 1
MERGE dbo.targetTable AS t
USING dbo.sourceTable AS s `enter code here`
ON (t.[key] = s.[key] and t.endDate is null) 
WHEN MATCHED  and s.[value] <> t.[value] 
THEN UPDATE SET t.enddate = dateadd(ss,-1,cast(cast(getdate() as date) as datetime))
WHEN not MATCHED 
THEN INSERT (key,[col1], [col2], [value], [col3],startdate,BatchLogID) 
    VALUES (s.key,s.[col1], s.[col2], s.[value], s.[col3],cast(getdate() as date),@batchLogID)

Used a sql merge command - had to wash through twice for

declare @batchLogID int= 1
MERGE dbo.targetTable AS t
USING dbo.sourceTable AS s `enter code here`
ON (t.[key] = s.[key] and t.endDate is null) 
WHEN MATCHED  and s.[value] <> t.[value] 
THEN UPDATE SET t.enddate = dateadd(ss,-1,cast(cast(getdate() as date) as datetime))
WHEN not MATCHED 
THEN INSERT (key,[col1], [col2], [value], [col3],startdate,BatchLogID) 
    VALUES (s.key,s.[col1], s.[col2], s.[value], s.[col3],cast(getdate() as date),@batchLogID)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文