SQL Server 2005 + VB.NET +桌面应用程序中插入查询中的时间计算 [英] Time cousuming in insert query in SQL Server 2005 + VB.NET + Desktop App

查看:84
本文介绍了SQL Server 2005 + VB.NET +桌面应用程序中插入查询中的时间计算的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

早安Friendz,

我在SQL Server 2005中保存数据时遇到一个独特的问题.

我有一个文本文件,其中有大量数据,例如.每个文件10L记录.在将这些数据保存到数据库时,我正在循环中使用SQL插入查询.
我已经使用 System.IO 命名空间与文本文件进行交互.以及 StreamReader 类的功能(.NET Framework为2.0).

它可以正确保存数据,但要花很多时间.
那是我的问题.
保存数据大约需要20到25分钟.

有什么省时的方法可以将数据保存到数据库中吗?

请在相同的位置进行指导.
非常感谢adv.

Good Morning friendz,

I have a unique problem to saving data in SQL Server 2005.

I have a text file in which there are large number of data, eg. 10L records in each file. And while saving the these data to database I am using SQL insert query in loop.
I have used System.IO namespace to interact with text file. And functions from StreamReader class(.NET Framework is 2.0).

It is saving data properly but taking to much time for the same.
And that''s my problem.
It''s taking almost 20 to 25 minutes to save data.

Is there any time saving way to save data in database ?

Please guide on the same.
Thanks in adv.

推荐答案

SQL Server在这方面非常糟糕,请在此处查看Bulk Insert:
批量插入(Transact-SQL) [使用批量插入来加载文本文件 [ ^ ]
SQL Server is notoriously bad in this regard, take a look at Bulk Insert here:
BULK INSERT (Transact-SQL)[^]

Using BULK INSERT to Load a Text File[^]


这篇关于SQL Server 2005 + VB.NET +桌面应用程序中插入查询中的时间计算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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