从远程SQL服务器获取记录并使用datatable保存到loacl SQL数据库的最快方法 [英] Fastest way to fetch records from remote SQL server and save to loacl SQL database using datatable

查看:66
本文介绍了从远程SQL服务器获取记录并使用datatable保存到loacl SQL数据库的最快方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我在远程sql server数据库中有一个超过100000条记录的客户表

cutomer table
ID

名称

电话

职业

性别



我还有一个4000个客户ID的列表。

从远程sql server获取客户数据并使用DataTable保存到本地sql数据库的最快方法是什么。 net。



我也会对任何不同的方式感兴趣。



谢谢



我尝试过的事情:



我在IN语句中使用但是当id超过3000时抛出错误



我会在临时表中插入客户ID并加入,但是这两个数据库不在同一服务器上托管。 br />


select * from customertable,其中id为('CUS1','CUS2','CUS3','CUS4','CUS5',......'CUS4000' )

Hi All,

I have a customer table with over 100000 records in a remote sql server database
cutomer table
ID
Name
Phone
Occupation
Gender

I also have a list of 4000 customer id's.
What will be the fastest way to fetch customer data from remote sql server and save to local sql database using DataTable in .net.

I will also be interested in any different way to achieve that.

Thanks

What I have tried:

I made used if the IN statement but throws an error when id's are more than 3000

I would have inserted customer ids in a temp table and joined but the two database are not hosted on the same server.

select * from customertable where id in ('CUS1','CUS2','CUS3','CUS4','CUS5',....'CUS4000')

解决方案

Richard Deeming [ ^ ]已经回答了您的问题(请参阅注释)你的问题),但我建议你阅读:如何将多个记录传递给存储过程 [ ^ ]和此:正确执行数据库操作 [ ^ ]



祝你好运!
Richard Deeming[^] already answered your question (see the comment to your question), but i'd suggest to read this: How to pass multiple records to a Stored Procedure[^] and this: Properly executing database operations[^]

Good luck!


这篇关于从远程SQL服务器获取记录并使用datatable保存到loacl SQL数据库的最快方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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