OiO.lk Blog SQL SQL importing XML with polish characters
SQL

SQL importing XML with polish characters


Hi I wanted to import data from an xml file containing polish characters, but it fails. My xml file is in utf8 format and I’m positive it’s not the problem. Columns in my table are nvarchar and I can “insert into” polish characters but not with the script or import wizard. This is my script:

USE db name

EXEC sp_configure 'show advanced options', 1;
RECONFIGURE;
EXEC sp_configure 'Ad Hoc Distributed Queries', 1;
RECONFIGURE;

DECLARE @xml NVARCHAR(MAX);

SELECT @xml = CONVERT(NVARCHAR(MAX), BulkColumn)
FROM OPENROWSET(BULK 'path to xml file', SINGLE_CLOB) AS x;

DECLARE @hDoc INT;

EXEC sp_xml_preparedocument @hDoc OUTPUT, @xml;


INSERT INTO mytable (column)
SELECT 
    z.column
FROM OPENXML(@hDoc, '/root/people/person', 2)
WITH (
    column NVARCHAR(50) 'column',
) AS z;

EXEC sp_xml_removedocument @hDoc;

Tried changing databases xml files importing through different ways encoding xml nothing works for polish characters only insert into but I have many data can’t do it 1 by 1.



You need to sign in to view this answers

Exit mobile version