Select into 语句,其中源是其他数据库 [英] Select into statement where source is other database
问题描述
如何将一个数据库中的数据复制到另一个表结构相同的数据库中,并保留关键身份?
How to copy data from one DB into another DB with the same table structure and keep the key identities?
我使用 Sql Server 2012Denali",我想从 Sql Server 2008 DB 复制一些数据.我拥有的表完全相同,但我希望将旧数据库中的数据放入新的Denali"数据库中.数据库位于不同的服务器上.
I use Sql Server 2012 "Denali" and I want to copy some data from a Sql Server 2008 DB. The tables I have are exactly the same but I want the data from the old DB into the new "Denali" DB. The databases are on different servers.
所以我想要类似的东西
USE newDB;
GO
SELECT *
INTO newTable
FROM OldDb.oldTable WITH (KEEPIDENTITY);
GO
有人有什么建议可以使这个可行吗?
Anyone have a suggestion to make this workable ?
推荐答案
配置链接服务器并在查询中引用它.您可能还需要使用 IDENTITY_INSERT
.
Configure a linked server and reference it in your query. You may need to use IDENTITY_INSERT
as well.
SSMS 中内置的 SSIS 组件还可以从不同来源(XML、平面文件或本地/远程服务器)加载数据.
The SSIS components built into SSMS can also load data from different sources (XML, flat file or a local/remote server).
这篇关于Select into 语句,其中源是其他数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!