XML parsing: line 1, character 7, text/xmldecl not at the beginning of input while running stored procedure

I have a csv file and want to bulk import all the csv file values into my table. I have written a stored procedure for it.

Problem is I have a table with columns of xml datatype. When I’m trying to import xml values from csv file to database its throwing XML parsing:

line 1, character 7, text/xmldecl not at the beginning of input

My stored procedure

SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO  ALTER PROCEDURE [dbo].[sp_CreateImportTempTable] AS BEGIN     SET NOCOUNT ON;      CREATE TABLE ImportData1     (         message XML,         status XML     )      BULK INSERT ImportData1 from 'C:\Temp\demo.csv'      WITH (             FIELDTERMINATOR = ',',             FIRSTROW = 2          ) END 

My csv has these values

first column: message

<?xml version="1.0" encoding="UTF-8"?><ixml xsi:noNamespaceSchemaLocation="example.xsd"  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><name><id/><nameType>argument</nameType>  <section/><division>no</division><Host/><content><Start><class/><interface><deviceId/><new>  <name>Ram</name><FullName>Ram Sath</FullName><version>1.0</version></new></interface></Start>  </content></name></ixml> 

second column: status

<?xml version="1.0" encoding="UTF-8"?><ixml xsi:noNamespaceSchemaLocation="demo.xsd"  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><name><id/><Type/><divison/><section/><Host/>  <content><Stop><section/></Stop></content></name></ixml> 

What is the issue here?

Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.