Skip to main content
Solved

How can a parent-child hierarchy be historicized using parent DW_Ids?

  • December 12, 2019
  • 1 reply
  • 44 views

How can a parent-child hierarchy be historicized using parent DW_Ids?

Best answer by Anonymous

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]

View original
Did this topic help you find an answer to your question?

1 reply

  • 0 replies
  • Answer
  • December 16, 2019

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings