Here is the scenario. I have two tables. I want to merge multiple row value to single value using update query.
DECLARE @Table as Table
(
id int,
name varchar(10)
)
insert into @Table values(1,'a')
insert into @Table values(1,'b')
insert into @Table values(1,'c')
select * from @Table
DECLARE @Table2 as Table
(
id int,
name varchar(10)
)
insert into @Table2 values(1,'a')
update t2 set name = t1.name from @Table2 t2
inner join @Table t1 on t1.id=t2.id
select * from @Table2
I want output from @Table2 as by using update query
id name
----- --------
1 a,b,c