简体   繁体   English

如何在不同的数据库服务器之间传输数据-没有SSIS,没有LinkedServer

[英]How to transfer data between different DB servers - No SSIS, No LinkedServer

How can I tranfer data between different DB Servers, this is a daily job, ie: 我如何在不同的数据库服务器之间传输数据,这是一项日常工作,即:

Insert into ServerA..table1
   select data from ServerB.table2.

(this is just an example, the real situation is we select data from many servers, and then do some join, then insert into the destination). (这只是一个示例,实际情况是我们从许多服务器中选择数据,然后进行一些联接,然后插入到目标中)。

We can not use SSIS , we can not use linked server , How can we do this? 我们不能使用SSIS ,我们不能使用链接服务器 ,我们该怎么做?

btw, this is a daily job, and the data is huge. 顺便说一句,这是一项日常工作,并且数据量巨大。

A simple command line BCP script should work for you. 一个简单的命令行BCP脚本应该适合您。 For instance: 例如:

bcp AdventureWorks2012.Sales.Currency out Currency.dat -T -c -SServer1
bcp AdventureWorks2012.Sales.Currency in Currency.dat -T -c -SServer2

Here's more details 这是更多细节

同步框架可能值得一看: http : //msdn.microsoft.com/en-us/sync/bb736753.aspx

Look at this question: SQL backup version is incompatible with this server 看这个问题: SQL备份版本与此服务器不兼容

The first options from my answer should work for your case 我的答案中的第一个选项应适合您的情况

My answer was converted into comment but I'm adding some more info. 我的回答已转换为评论,但我添加了更多信息。

I guess you are looking for this answer on SO: 我想您正在寻找这样的答案:

What is the best way to auto-generate INSERT statements for a SQL Server table?

Once you have the code, just add USE your_databasename_where_to_copy_data at the begining, execute and voila 获得代码后,只需在开始处添加USE your_databasename_where_to_copy_data ,然后执行即可

Edit: As you want to do it on the fly, using code, try some of the solutions provided on this question on SO . 编辑:当您想使用代码即时进行操作时,请尝试在SO上针对此问题提供的一些解决方案。 Basically it is similar to your code proposal, with some few differences, as for example: 基本上,它与您的代码建议相似,但有一些区别,例如:

INSERT INTO bar..tblFoobar( *fieldlist* )
SELECT *fieldlist* FROM foo..tblFoobar

您可以使用C#.net SqlBulkCopy方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM