是否可以在没有文件的情况下使用sql server批量插入?
很好奇这是否可能:应用程序服务器和数据库服务器位于不同的地方(显然)。应用程序服务器当前生成一个用于 sql server 批量插入的文件。
这要求数据库和应用服务器都能够看到位置,这使得在不同环境下的配置变得更加困难。
我想知道的是:在这种情况下是否可以绕过文件系统?也许我可以将数据传递给sql server并让它生成文件?
我使用的是 sql server 2008,如果这有什么区别的话。
谢谢!
Curious if this is possible: The app server and db server live in different places (obviously). The app server currently generates a file for use with sql server bulk insert.
This requires both the DB and the app server to be able to see the location, and it makes configuration more difficult in different environments.
What I'd like to know is: is it possible to bypass the file system in this case? Perhaps I can pass the data to sql server and have it generate the file?
I'm on sql server 2008, if that makes a difference.
thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

发布评论
评论(2)
来自批量插入的文档:
BULK INSERT
[ database_name. [ schema_name ] . | schema_name. ] [ table_name | view_name ]
FROM 'data_file'
FROM 'data_file' 不是可选的,并且指定如下:
'数据文件'
是包含要导入到的数据的数据文件的完整路径
指定的表或视图。批量插入
可以从磁盘导入数据(包括
网络、软盘、硬盘等
等等)。data_file 必须指定有效路径
从 SQL Server 所在的服务器
跑步。如果 data_file 是远程文件
文件,指定通用命名
约定 (UNC) 名称。 UNC 名称有
形式
\系统名称\共享名\路径\文件名。
例如,
\SystemX\DiskZ\Sales\update.txt。
您的应用程序可以使用满足您的性能需求的任何方法直接执行插入。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
我不认为你可以使用 SQL Server 的bulkcp 工具来做到这一点,但如果你的应用程序是使用 .NET 编写的,你可以使用 System.Data.SqlClient.SqlBulkCopy 类从数据表(或任何你想要的数据源)批量插入行。可以使用 SqlDataReader 进行访问)。
I don't think you can do that with SQL Server's bulkcp tool, but if your app is written using .NET, you can use the System.Data.SqlClient.SqlBulkCopy class to bulk insert rows from a data table (or any datasource you can access with a SqlDataReader).