sql
USE tempdb
GO
Create TABLE #t1 (c1 int NOT NULL, c2 char(5), c3 char(5),
c4 char(5))
GO
Create TABLE #t2 (c1 int NOT NULL, c2 char(5), c3 char(5),
c4 char(5))
GO
--数据赋值
Insert #t1 values (1,'hello','there','fred')
Insert #t2 values (1,'how','are','you?')
--更新数据
Update #t1 SET #t1.c2 = #t2.c2, #t1.c3 = #t2.c3,
#t1.c4 = #t2.c4
FROM #t2
Where #t1.c1 = #t2.c1
--检查结果
Select * FROM #t1
==============================
select top 0 * into B from A
insert B select * from A
GO
Create TABLE #t1 (c1 int NOT NULL, c2 char(5), c3 char(5),
c4 char(5))
GO
Create TABLE #t2 (c1 int NOT NULL, c2 char(5), c3 char(5),
c4 char(5))
GO
--数据赋值
Insert #t1 values (1,'hello','there','fred')
Insert #t2 values (1,'how','are','you?')
--更新数据
Update #t1 SET #t1.c2 = #t2.c2, #t1.c3 = #t2.c3,
#t1.c4 = #t2.c4
FROM #t2
Where #t1.c1 = #t2.c1
--检查结果
Select * FROM #t1
==============================
select top 0 * into B from A
insert B select * from A