I am trying to create a single row that includes an Assembly number and each component.
I have a table called Assembly
with a Unique Identifier that can be tied back to the inv_mast
table as well as Components in that table that can be tied back to the same inv_mast
table. It also includes a sequence number.
inv_mast_uid | sequence_number | component_inv_mast_uid
453061 | 1 | 453024
453061 | 2 | 453017
453061 | 3 | 453020
453062 | 1 | 453019
453062 | 2 | 453027
(Some of my entries only have 2 Components)
What I am trying to achieve is:
inv_mast_uid | component_inv_mast_uid_1 | component_inv_mast_uid_2 | component_inv_mast_uid_3
453061 | 453024 | 453017 | 453020
453062 | 453019 | 453027 | Null
I was thinking I would use a 'For Each` loop, but I've never had any luck with it and SQL Server