在SQL Server中插入大量数据 [英] large amont of data insert in sql server

查看:469
本文介绍了在SQL Server中插入大量数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在excel工作表中有大量数据.我想将这些数据插入sql数据库中.
Excel工作表包含1000条记录.
我为此写代码.
我在sql中选择哪种数据类型以允许所有类型的数据,例如空格,特殊字符,数字和字符

解决方案

如果您需要快速的方法,可以使用SqlBulkCopy它的速度很快,我相信它将解决您的目的.在此处查看文章SqlBulkCopy [ ^ ].

首先需要创建一个表格,以便导入excel数据

如果您不确定数据,则创建数据类型为

  VARCHAR (MAX)

的列,否则选择根据excel单元格中的值"选择适当的数据类型.

您可以使用适用于SQL Server 2000的DTS包或适用于SQL Server 2005及更高版本的SSIS导入此数据,也可以在excel文件中创建一个宏,该宏会将数据插入到表中,也可以在c#中执行此操作. br/>
您可以引用 SSIS
DTS


请参阅以下讨论: 解决方案

If you need a fast way, you can use SqlBulkCopy its fast and I believe it will solve your purpose. Check out the article for SqlBulkCopy over here[^].


First thing you need to create a table for the excel data to import

If you are not sure about the data then create columns with data type as

VARCHAR(MAX)

or else the choose the appropriate data types as per the Value in the excel cell.

you can import this data using DTS Package for SQL Server 2000 or SSIS for SQL Server 2005 and above or else you can create a macro in excel file that will insert the data to the table and also you can do this in c# also..

You can refer SSIS
DTS


please see this discussion: import MS Excel to datatable[^]


这篇关于在SQL Server中插入大量数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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