“选择*到表中”将数据插入现有表是否可行 [英] "select * into table" Will it work for inserting data into existing table

查看:80
本文介绍了“选择*到表中”将数据插入现有表是否可行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将数据从现有表中的一个插入到另一个现有表中。

I am trying to insert data from one of my existing table into another existing table.

是否可以使用<$ c $将数据插入任何现有表中c>选择*进入查询。
我认为可以使用并集完成操作,但是在那种情况下,我需要将现有表的所有数据记录到临时表中,然后删除该表,最后再应用并集将所有记录插入同一张表中

Is it possible to insert data into any existing table using select * into query. I think it can be done using union but in that case i need to record all data of my existing table into temporary table, then drop that table and finally than apply union to insert all records into same table

例如

select * into #tblExisting from tblExisting
drop table tblExisting
select * into tblExisting from #tblExisting union tblActualData

这里tblExisting是我在其中的表格实际上是要存储所有数据
tblActualData是将数据附加到tblExisting的表。

Here tblExisting is the table where I actually want to store all data tblActualData is the table from where data is to be appended to tblExisting.

这是正确的方法吗?
我们还有其他选择吗?

推荐答案

您应该尝试

INSERT INTO ExistingTable (Columns,..)
SELECT Columns,...
FROM OtherTable

看看插入

SQL SERVER –从一个表中插入数据到另一个表–插入选择–选择表

这篇关于“选择*到表中”将数据插入现有表是否可行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆