如何从database1插入数据到database2注意它们没有相同的服务器 [英] how to insert a data from database1 to database2 note they dont have the same server

查看:60
本文介绍了如何从database1插入数据到database2注意它们没有相同的服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试了这段代码,但没有任何反应.

I tried this code but nothing happens.

connection1 cn1 = new connection();
connection2 cn2 = new connection();

datatable dt;

dt = cn1.getrecords("select id,name from users");

for(int x=0;x<getrecords.rows.count;x++)>
{
cn2.insert("insert into tbl_users(id,name) values('"+dt.rows[x]["id"].tostring()+"','"+dt.rows[x]["name"].tostring()+"')");
}

推荐答案

您需要使用 ^ ].
这里有一篇文章显示了它的运行情况:使用SqlBulkCopy传输数据 [ ^ ]
You need to look at using the SqlBulkCopy class[^].
There is an article here which shows it in action: Transferring Data Using SqlBulkCopy[^]


使用链接的服务器并在其中插入一个sp,然后使用该sp
使用复制
使用DTS/SSIS进行
Use linked Server and create a sp in insert it and use that sp
Use replication
Use DTS/SSIS to do it


这篇关于如何从database1插入数据到database2注意它们没有相同的服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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