数据库之间的SQL数据传输 [英] SQL Data Transfer between databases

查看:116
本文介绍了数据库之间的SQL数据传输的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个数据库

我希望能够使用C#将特定数据从一个数据传输到另一个数据,是否有一种简单的方法可以将包含所有相关数据的选定记录从一个数据库传输到具有完全相同的表模式的另一个数据库.

请记住,这还必须提取关系数据,

我知道插入选择,并且很可能没有现成的解决方案,但是有没有人遇到过可以使用的框架?

I have two databases

I want to be able to transfer specific data from one to the other using C#, is there a easy way to transfer a selected record including all related data from one database to another database that has the exact same table schema.

Please keep in mind this also has to pull the relational data ,

I know about insert selects and most probably there''s no out-of-box solution for this but has anyone came across a framework I can use ?

推荐答案

下面查询从testsource数据库的employee表中传输所有数据
到测试目标数据库的员工表


Below query transfers all the data from employee table of testsource database
to employee table of testdestination database


insert into TestDestination.dbo.Employee 
select * from TestSource.dbo.Employee 




对于要传输的特定数据,您将为select添加where子句,如下所示




for the specific data to transfer you will add where clause for the select as follows

insert into TestDestination.dbo.Employee 
select * from TestSource.dbo.Employee 
Where Id > 10 and Id < 20


尝试以下操作:

插入到TargetDB.dbo.TargetTable(ColumnID,SomeColumn1,SomeColumn2)

SELECT ColumnID,SomeColumn1,SomeColumn2

FROM SourceTable
try the following :

INSERT INTO TargetDB.dbo.TargetTable (ColumnID, SomeColumn1, SomeColumn2)

SELECT ColumnID, SomeColumn1, SomeColumn2

FROM SourceTable




您想要将数据从DB1中的一个表复制到DB2中的另一表.
我们可以使用像... solution1
这样的sql命令来做到这一点
另一个正在使用c#.

例如首先从一个数据库中检索数据,然后将检索到的数据插入另一个数据库中.


如果您明确指定表定义,我可以轻松解决您的要求.

希望您能理解我的意思.
Hi,

You want to copy data from one table in DB1 to another table in DB2 .
we can do this by using sql command like...solution1

and another one is using c#.

like first retrieve data from one database and then insert that retrieced into another database.


If you clearly specify your table definitions I can easily solve your requirement.

I hope you understood what I said.


这篇关于数据库之间的SQL数据传输的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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