Alex Rivera | Logout

Why do I get "XML parsing: line 2, character 0, incorrect document syntax" when Bulk Inserting in MS SQL Server

Asked 2010-01-28T13:02:50.767
12

I'm doing a BULK INSERT into a table using a FMT format file, but I get the following error:

XML parsing: line 2, character 0, incorrect document syntax

Here is my code

BULK INSERT [DM_Flux].[dbo].[Stage] FROM 'C:\temp\data.dat'
WITH (FORMATFILE = 'C:\temp\FormatBcp.fmt')

Here is the formatfile (standard format file, not XML):

10.0
5
1   SQLCHAR 0   2   ""  1   Id  ""
2   SQLCHAR 0   40  ""  2   Name    ""
3   SQLCHAR 0   50  ""  3   Street  ""
4   SQLCHAR 0   8   ""  4   StreetNo    ""
5   SQLCHAR 0   300 "\r\n"  7   BulkData    ""

Why do I get an XML error with this?

Edit
Report

1 Answer

8

A good way to ensure that the MS SQL server is not failing to read the version format, downgrade the version number in the .FMT file. Change V10.0 to 9.0 or lower. MS SQL 2008 can read a lower version but 2005 cannot read a higher version. So downgrading the version numer might help solve the problem.

Version number of the bcp utility:

 9.0 = SQL Server 2005 
10.0 = SQL Server 2008
11.0 = SQL Server 2012
12.0 = SQL Server 2014

For non XML format file you can refer to the Microsoft page: http://msdn.microsoft.com/en-us/library/ms191479.aspx.

answered 2012-07-17T09:29:37.490

Your Answer