Reputation: 7758
Using the table structure below how would I create a bcp bulk insert that would handle the XML data. It is important that this is run from command line.
CREATE TABLE [dbo].[MyTable](
[Id] [uniqueidentifier] NOT NULL DEFAULT (newid()),
[MyXmlField] [xml] NULL
Thanks in advance...
Upvotes: 2
Views: 5947
Reputation: 22950
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.
Upvotes: 0
Reputation: 8335
The basic syntax for using bcp is:
bcp <table_name> <direction> <file_name> <options>
Where the arguments take the following values:
Will need more info to know what switches to use, but it should be somehting like
bcp database.dbo.MyTable in "C:\folder\xmlfile.xml" -c -T
-c Performs the operation using a character data type.
-T Specifies that the bcp utility connects to SQL Server with a trusted connection using integrated security.
Also here is Microsoft's bcp Utility which should help you with knowing what switches to use.
Upvotes: 2