将大量数据复制到SQL CE数据库中 [英] Copying large amounts of data into a SQL CE database
问题描述
如果内存中有大量数据,将其复制到SQL CE表的最佳方法是什么?当前的技术堆栈是C#,ADO.net和SQL CE。
If I have a large amount of data in memory, what is the best way to copy it into a SQL CE table? The current technology stack is C#, ADO.net, and SQL CE.
我最初的想法是为每行数据执行一个INSERT语句,但这是时间。消耗。有没有更简单的方法?
My initial idea was to do one INSERT statement for each row of data, but this is time-consuming. Is there an easier way?
推荐答案
突然出现在我头上的是与桌面或桌面进行同步/合并。服务器数据库,尽管听起来并不像它真正满足您的需求。所以这是我的第二个想法:
The first thing that popped into my head was to do a sync/merge with a desktop or server database, though that doesn't sound like it really fits your needs. So here is my second thought:
从数据文件中批量插入表名
BULK INSERT table_name FROM data_file
我不确定是否支持在您的SQL CE版本中(尽管从我在MSDN页面上可以看出,它似乎在3.5 SP1中受支持)。 http://msdn.microsoft.com/en-us/library/ms188365.aspx
I am not sure if it is supported in your version of SQL CE (though it appears to be supported in 3.5 SP1 from what I can tell on the MSDN pages). http://msdn.microsoft.com/en-us/library/ms188365.aspx
您还可以在插入数据时禁用表上的任何索引,以加快处理速度,然后在完成插入后启用/重建索引。
You could also disable any indexes on the table while inserting the data to speed things up, then enable/rebuild the index once you are done inserting.
这篇关于将大量数据复制到SQL CE数据库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!