Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Development - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 3145

Hierarchy design to have equal levels in each tree.

$
0
0
Hi All,I have a requirement, where i need to have a equal levels in each hierarchy. I am trying to use the recursive CTE's but could not get the exact logic.I have a table as below:product_cd product_desc product_parent_cd product_idTOTPROD Total Commercial Beverages NULL 1BT01 Non-Alcoholic Ready-To-Drink Beverages TOTPROD 2BC02 Packaged Water, RTD BT01 17BS991 Packaged Water Plain, RTD BC02 60BS999 Packaged WaterEnhanced, RTD BC02 19BS998 Packaged Water Bulk, RTD BS991 18I want the below sample output to make the hierarchy equal as above.BS010 Packaged Water Pouch, RTD BS991 50BC01 Beer BT02 33BT02 Alcoholic Beverages TOTPROD 4BC01d1 Beer BC01 33BC01d1d1Beer BC01d1 33Can any one help me on this?

Viewing all articles
Browse latest Browse all 3145

Trending Articles