I have this challenging problem. I have 2 tables : Table A and Table B, the two tables are linked by an ID column.
I want to update the 'Desc' field of table B as a comma delimited string pulled from the description column in Table A
linked by the ID field as given below;
Desired updated Table B;
How do i achieve this. I have a query that transforms the column into string but the update statement does not work properly"
declare @num1 int
select @num1 = (select top 1 ID from TableA)
@num1 In (select ID from TableA)
DECLARE @colors VARCHAR(1024)
@colors = COALESCE(@colors + ',', '') + (tbl1.Desc)
FROM TableA tbl1,TableB tbl2
where tbl1.ID = tbl2.ID
and rpt.ID = @num1
SELECT Colors = @colors
set Desc= @colors
where ID in (select top 1 ID from TableA)