I have 4 tables that have 2 columns each.
'Column 1' is the 'One' 'Column 2' is the 'Many'
Column 1 has several different ID's that i need to group somehow and build a delimited string of all the 'Columns 2' values.
I need to do this for every distinct 'Column 1' value.... is this possible?
So for example i have this table..
DECLARE @tblDeadsData TABLE (
[ID] INT IDENTITY(1,1) NOT NULL,
[ContainerID] INT NULL,
[DeadsID] INT NULL
)
It is already populated with data, i need to build a delimited string of ALL the [DeadsID] for each [ContainerID], and then these delimited string need to be placed into this table (the DeadsDataTable Data goes into the tblLastMerge.DeadsIDList in this case)..
CREATE TABLE tblLastMerge(
[ID] INT IDENTITY(1,1) NOT NULL,
[FeedLotID] INT NULL,
[ContainerID] INT NULL,
[ContainerName] VARCHAR(40) NULL,
[IsMergeTargetContainer] BIT NULL,
[PurchaseIDList] VARCHAR(1000) NULL,
[DeadsIDList] VARCHAR(1000) NULL,
[RailersIDList] VARCHAR(1000) NULL,
[FeedBillIDList] VARCHAR(1000) NULL
)
***************************EDIT********************************* in regards to the duplicate post.........Concatenation is not delimited!!!!!! no wonder when i did a search for my problem i did not see this post..... i do think you should link these 2 post though as i found an answer much more simplified compared to the (supposedly) original post