Good Afternoon AllI have a project of data migration from old system to new system. The new system needs a flat pipe file in a specific format.On my Ben table, I have an ID that could have multiple records, lets say ten records. This is a table used to store a clients beneficiaries of mobile numbers. 1 client can have many beneficiaries with different mobile numbers.I want to select this data into a single ID with all the records per column. Example as per below.BENID |NUM| Amount|Cur|date| T01 | 123 | 50.00 | NAD | 20160818|T01 | 124 | 20.00 | NAD | 20160817|T02 | 125 | 30.00 | NAD | 20160816|T02 | 126 | 10.00 | NAD | 20160815|T03 | 127 | 40.00 | NAD | 20160814|Desired outputID | NUM | Amount |Cur |date | T01 | 123::124 | 50.00::20.00 | NAD::NAD | 20160818::20160817|T02 | 125::126 | 30.00::10.00 | NAD::NAD | 20160816::20160815|T03 | 127 | 40.00 | NAD | 20160814|The current query I have is this and is not giving what i want.[code="sql"]Select Main.ID, Left(Main.BEN,Len(Main.BEN)-1) As "Data"From ( Select distinct ST2.ID, ( Select ST1.mobile_number + '::' AS [text()], ST1.amount + '::' AS [text()] From MTCBEN ST1 Where ST1.ID = ST2.ID ORDER BY ST1.ID For XML PATH ('') ) [BEN] From MTCBEN ST2 ) [Main][/code]Thank you so much for your help guys.. This will save my life.Regards
↧