是否可以在没有文件的情况下使用sql server批量插入?

发布于 09-18 01:35 字数 241 浏览 9 评论 0原文

很好奇这是否可能:应用程序服务器和数据库服务器位于不同的地方(显然)。应用程序服务器当前生成一个用于 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 技术交流群。

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

发布评论

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

评论(2

-残月青衣踏尘吟2024-09-25 01:35:14

我不认为你可以使用 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).

凑诗2024-09-25 01:35:14

来自批量插入的文档:

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。

您的应用程序可以使用满足您的性能需求的任何方法直接执行插入。

From the documentation on bulk insert:

BULK INSERT 
   [ database_name. [ schema_name ] . | schema_name. ] [ table_name | view_name ] 
      FROM 'data_file' 

The FROM 'data_file' is not optional and is specified as such:

'data_file'
Is the full path of the data file that contains data to import into the
specified table or view. BULK INSERT
can import data from a disk (including
network, floppy disk, hard disk, and
so on).

data_file must specify a valid path
from the server on which SQL Server is
running. If data_file is a remote
file, specify the Universal Naming
Convention (UNC) name. A UNC name has
the form
\Systemname\ShareName\Path\FileName.
For example,
\SystemX\DiskZ\Sales\update.txt.

Your application could do the insert directly using whatever method meets your performance needs.

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