[id] int,
[desc] nvarchar(100)
)
insert into @Tab1 ([id], [desc]) values (1, 'first description');
insert into @Tab1 ([id], [desc]) values (2, 'second description');
insert into @Tab1 ([id], [desc]) values (3, 'third description');
insert into @Tab1 ([id], [desc]) values (4, 'fourth description');
insert into @Tab1 ([id], [desc]) values (5, 'fifth description');
select * from @Tab1
DECLARE @Tab2 TABLE (
[id] int,
[desc] nvarchar(100)
)
insert into @Tab2 ([id], [desc]) values (1, 'new first description');
insert into @Tab2 ([id], [desc]) values (2, 'new second description');
insert into @Tab2 ([id], [desc]) values (3, 'new third description');
insert into @Tab2 ([id], [desc]) values (4, 'new fourth description');
insert into @Tab2 ([id], [desc]) values (5, 'new fifth description');
select * from @Tab2;
update @Tab1
set [desc] = T2.[desc]
from @Tab1 AS T1
inner join (
select *
from @Tab2
) AS T2 ON T1.id = T2.id
select * from @Tab1;
Nessun commento:
Posta un commento