Skip to content

Instantly share code, notes, and snippets.

@markmo
Created March 19, 2013 02:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markmo/5193235 to your computer and use it in GitHub Desktop.
Save markmo/5193235 to your computer and use it in GitHub Desktop.
Update Parent Key in Hierarchical Set
UPDATE RetDay.dimProductCategoryHierarchy SET
ParentCategoryKey = (
SELECT TOP 1 ProductCategoryMappingKey
FROM RetDay.dimProductCategoryHierarchy
WHERE ProductCategoryCode = P.ParentCategoryCode
AND DETL_RowIsCurrent = 1)
FROM RetDay.dimProductCategoryHierarchy P
WHERE P.ParentCategoryKey IS NULL
AND P.ParentCategoryCode <> ' '
AND P.ParentCategoryCode IS NOT NULL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment