从Excel批量插入SQL Server

发布于 2024-12-25 05:11:35 字数 130 浏览 2 评论 0 原文

有没有办法从 Excel 中的一行数据在 SQL Server 上进行批量更新?我们有包含 2000 多行的 Excel 文档,需要导入到 SQL Server 中。有没有一种方法可以批量插入这些家伙,而无需一遍又一遍地调用数据库来一次插入一行?

Is there a way to do a batch update on SQL Server from a row of data in Excel? We have excel documents that contain 2000+ plus rows and need to be imported in SQL Server. Is there a way to do a batch insert of these guys without calling the database over and over to insert one row at a time?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

寻找一个思念的角度 2025-01-01 05:11:35

SQL Server Integration Services 提供基于向导的导入,可以帮助您轻松设置包以导入 Excel 文件。您甚至可以保存包并安排它在将来重复导入。

您还有其他选择。如果将 Excel 文件保存为逗号或制表符分隔的文本文件,则可以使用 BULK INSERT t-sql 命令。请参阅sqlteam.com 论坛上的示例

另一个 T-SQL 选项是 SELECT INTO。 Excel 是来自 T-SQL 的有效 OLEDB 或 ODBC 数据源。 这是一个示例

Microsoft SQL Server 中还包含一个名为 BCP 的命令行导入工具。有关 BCP 和其他选项的详细文档可以在 MSDN 上找到:http://msdn.microsoft.com /en-us/library/ms187042.aspx

SQL Server Integrations Services offers a wizard based import which can help you easily set up a package to import an excel file. You can even save the package and schedule it to repeat the import in the future.

You have other options, as well. If you save the excel file to a comma or tab delimited text file, you can use the BULK INSERT t-sql command. See an example on the sqlteam.com forums.

Another T-SQL option is SELECT INTO. Excel is a valid OLEDB or ODBC data source from T-SQL. Here's an example.

There's also a command line import tool included with Microsoft SQL Server called BCP. Good documentation on BCP and the other options can be found on MSDN at: http://msdn.microsoft.com/en-us/library/ms187042.aspx

羁客 2025-01-01 05:11:35

您可以创建 SSIS 包来读取 Excel 文件。当您创建任务时,您可以选择连接类型“Excel”,然后它会帮助您创建一个“Excel连接管理器”。然后您可以轻松地将数据发送到 SQL Server 表。这是关于 如何将 Excel 文件导入 SQL Server (2005)。看看吧。

You can create an SSIS package to read your Excel file. When you create your task, you can select a connection type of "Excel", and then it helps you create an "Excel Connection Manager". Then you can easily send the data to your SQL Server table. Here's a tutorial on how to import an Excel file into SQL Server (2005). Give it a look.

最好是你 2025-01-01 05:11:35

是的!使用 SSMS 的导入/导出向导!使用 Excel 源和 SQL Server 目标。如果您将 Excel 工作表转换为 CSV 文件,您还可以在 BIDS 中创建 SSIS 包或使用 T-SQL 中的 BULK INSERT 语句。

Yes! Use the import/export wizard of the SSMS! Use an Excel-source and a SQL Server destination. You can also create a SSIS-Package in the BIDS or use the BULK INSERT-statement from T-SQL, if you convert your Excel-sheets in to CSV-files.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文