Skip to content
Advertisement

How to split a table into Master/Detail, with generating id SSIS?

I stored a flat file into a table.

The tag P is for the master The tag I is for the detail

Always a P row was precede with a (n) numbers of I rows.

The problem is, The I rows doesn’t have an ID to join the P row.

Need to generate an ID to join the P row with the I rows.

The P row have a two fields that can be helpful. The field “SequenceNumber” store the sequential ID. The field “NumberOfItems” store how many I rows belong to a P Row.

I Need to split the data in two tables master/detail with identifiying ID. I attach an image with the data

Thanks So Much

SQL TABLE TO SPLIT

Advertisement

Answer

My primary concern is that you do not have a proper row sequence in the original table. Without this, this is no way to GTD the ordered data set.

In anticipation of you correcting this, I added a column called RowSeq

Example or dbFiddle

Returns

enter image description here

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement