Skip to main content
How can a parent-child hierarchy be historicized using parent DW_Ids?

Hi Dennis


you could consider creating a custom view on your History table, where the parent node is a type 2 field. Or a T-SQL script to update the rows directly.


This may not work in all cases, but serves as an example:


CREATE VIEW [dbo].[ParentChildBasedOnDWID]
AS


SELECT
a.[Node]
,a.[Parent]
,a.[DW_Id] as NodeDWID
,parent.DW_Id as ParentDWID
,a.[SCD Is Current]
,a.[SCD From DateTime]
,a.[SCD To DateTime]
,parent.[SCD From DateTime]
,parent.[SCD To DateTime]
FROM [ParentChild_Sheet1$_v] a
left join [ParentChild_Sheet1$_V] parent on parent.Node = a.parent
and parent.[SCD From DateTime] <= a.[SCD from DateTime]
and parent.[SCD To DateTime] >= a.[SCD From DateTime]


Reply