Question

I need to read large XML file to database (SQL Server 2008 R2). The whole XML file needs to be inserted into single database, single table and single column. After that it will be processed further.

1) I have a flat file connection manager to file:

  • Locale:Finnish Code

  • page:1252 (Ansi - Latin I)

  • Unicode unchecked

  • DataType: text stream, DT_TEXT

2) Data conversin task where data is transformed to unicode text stream DT_NTEXT

3) DT_NTEXT type of data in inserted to table column

When executing, steps 1) and 2) go OK, but insert fails with an error:

XML parsing: line 1, character 38, unable to switch the encoding

Without the data transformation task can't be executed because of an error: cannot convert between unicode and non-unicode string data types

Character 38 refers to first line, end of the line:

<?xml version="1.0" encoding="utf-8"?>

ending > is where it fails...and if the whole XML declaration line is deleted then it fails to next >.

I've read that (for some reason) changing the encoding to UTF-16 helps. But derived column and it's replace function won't work with TEXT or NTEXT. The file is so big that DT_WSTR and it's max length aren't enough.

Data flow is this simple...

XML data source -- loading= derived column --> DB destination">

I'm OK to use other ways as well...the point is just to read the whole xml file (~14 MBs) to single database column

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top