使用下面的表结构,我将如何创建一个处理 XML 数据的 bcp 批量插入。从命令行运行这一点很重要。
CREATE TABLE [dbo].[MyTable](
[Id] [uniqueidentifier] NOT NULL DEFAULT (newid()),
[MyXmlField] [xml] NULL
提前致谢...
使用下面的表结构,我将如何创建一个处理 XML 数据的 bcp 批量插入。从命令行运行这一点很重要。
CREATE TABLE [dbo].[MyTable](
[Id] [uniqueidentifier] NOT NULL DEFAULT (newid()),
[MyXmlField] [xml] NULL
提前致谢...
使用 bcp 的基本语法是:
bcp <table_name> <direction> <file_name> <options>
其中参数采用以下值:
需要更多信息才能知道要使用哪些开关,但它应该有点像
bcp database.dbo.MyTable in "C:\folder\xmlfile.xml" -c -T
-c使用字符数据类型执行操作。
-T指定 bcp 实用程序使用集成安全性通过可信连接连接到 SQL Server。
这里还有Microsoft 的 bcp Utility,它可以帮助您了解要使用的开关。
use -N switch if your file contains unicode characters.
-N : Performs the bulk-copy operation using the native (database) data types of the data for noncharacter data, and Unicode characters for character data. This option offers a higher performance alternative to the -w option, and is intended for transferring data from one instance of SQL Server to another using a data file. It does not prompt for each field. Use this option when you are transferring data that contains ANSI extended characters and you want to take advantage of the performance of native mode.