Sha*_*pta 17 sql t-sql database sql-server sql-server-2005
我试图将我现有的一个表中的数据插入到另一个现有表中.
是否可以使用select * into 查询将数据插入任何现有表.我认为可以使用union完成,但在这种情况下,我需要将现有表的所有数据记录到临时表中,然后删除该表,最后应用union将所有记录插入到同一个表中
例如.
select * into #tblExisting from tblExisting
drop table tblExisting
select * into tblExisting from #tblExisting union tblActualData
Run Code Online (Sandbox Code Playgroud)
这里tblExisting是我实际想要存储所有数据的表tblActualData是将数据附加到tblExisting的表.
这是正确的方法.我们还有其他选择吗?
Adr*_*der 25
你应该试试
INSERT INTO ExistingTable (Columns,..)
SELECT Columns,...
FROM OtherTable
Run Code Online (Sandbox Code Playgroud)
看看INSERT
和SQL SERVER - 将数据从一个表插入另一个表 - INSERT INTO SELECT - SELECT INTO TABLE
| 归档时间: |
|
| 查看次数: |
58352 次 |
| 最近记录: |