I have a wide table that contains 60+ columns for UPS/Fedex tracking numbers. I am trying to reduce the number of columns and have a parent to child relationship.
SELECT
[TRACKING-NO1], [TRACKING-NO2], [TRACKING-NO3], [TRACKING-NO4],
[TRACKING-NO5], [TRACKING-NO6], [TRACKING-NO7], [TRACKING-NO8],
[TRACKING-NO9], [TRACKING-NO10]
FROM
[CustomerServiceOrderEntry].[dbo].[InvoicedOrdersTempTable]
WHERE
[TRACKING-NO2] IS NOT NULL
The output returns a list of all the tracking numbers in one row (60+) columns. If there are child tracking numbers, then columns 2 - 60 will be populated; If there are no child tracking numbers, 2 - 60 will be NULL.
What I would like to do is have a parent tracking number and the associated child tracking number, and a flag to indicate it is a child.
Any help you can provide would be greatly appreciated...