| Author |
Topic |
|
cbeganesh
Posting Yak Master
105 Posts |
Posted - 2005-06-01 : 11:52:54
|
| Im trying to load an xml document to sql server using sp_xml_preparedocument . The xml document has utf-8 as encoding. Im getting this error"System.Data.SqlClient.SqlException: XML parsing error: Switch from current encoding to specified encoding not supported"Any help on this is appreciated |
|
|
raclede
Posting Yak Master
180 Posts |
Posted - 2005-06-02 : 00:58:22
|
My suggestion if to create an SP that will execute the sp_xml_preparedocument command, and thisSP just call it in .NET"If the automobile had followed the same development cycle as the computer, a Rolls-Royce would today cost $100, get a million miles per gallon, and explode once a year, killing everyone inside. " raclede |
 |
|
|
Merkin
Funky Drop Bear Fearing SQL Dude!
4970 Posts |
Posted - 2005-06-02 : 01:04:44
|
| It looks like that is what he is doing raclede.DamianIta erat quando hic adveni. |
 |
|
|
eyechart
Master Smack Fu Yak Hacker
3575 Posts |
Posted - 2005-06-02 : 02:24:53
|
quote: Originally posted by cbeganesh Im trying to load an xml document to sql server using sp_xml_preparedocument . The xml document has utf-8 as encoding. Im getting this error"System.Data.SqlClient.SqlException: XML parsing error: Switch from current encoding to specified encoding not supported"Any help on this is appreciated
How are you doing this exactly? Can you post some of your code?Also, are you using unicode datatypes for variables in your code?-ec |
 |
|
|
raclede
Posting Yak Master
180 Posts |
Posted - 2005-06-02 : 02:50:19
|
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=50531"If the automobile had followed the same development cycle as the computer, a Rolls-Royce would today cost $100, get a million miles per gallon, and explode once a year, killing everyone inside. " raclede |
 |
|
|
cbeganesh
Posting Yak Master
105 Posts |
Posted - 2005-06-02 : 09:30:43
|
| Yes, From DOT NET, Im creating the xml document and the output xml has encoding="utf-8". Im calling a stored procedure from dot net that used sp_xml_prepared document and then inserting into table using open xml. If i remove the encoding="utf-8" from the xml document, It works fine. |
 |
|
|
eyechart
Master Smack Fu Yak Hacker
3575 Posts |
Posted - 2005-06-02 : 10:17:50
|
quote: Originally posted by cbeganesh Yes, From DOT NET, Im creating the xml document and the output xml has encoding="utf-8". Im calling a stored procedure from dot net that used sp_xml_prepared document and then inserting into table using open xml. If i remove the encoding="utf-8" from the xml document, It works fine.
are you using unicode datatypes on the sql server side? specifically, are you using an ntext datatype?-ec |
 |
|
|
cbeganesh
Posting Yak Master
105 Posts |
Posted - 2005-06-02 : 11:31:44
|
| yes Im getting the xmldocument as ntext datatype |
 |
|
|
eyechart
Master Smack Fu Yak Hacker
3575 Posts |
Posted - 2005-06-02 : 13:23:39
|
quote: Originally posted by cbeganesh yes Im getting the xmldocument as ntext datatype
Well, if you want any real help from the group here you are going to have to post some code.Usually and error like this is due to not using unicode datatypes, but you indicate that you are.-ec |
 |
|
|
cbeganesh
Posting Yak Master
105 Posts |
Posted - 2005-06-02 : 14:41:07
|
| Here is the codeALTER PROCEDURE uspInsertXml (@FileContents ntext)ASDECLARE @iDoc intDECLARE @FileName varchar(255)DECLARE @ExecCmd VARCHAR(255)DECLARE @y INTDECLARE @x INTEXECUTE sp_xml_preparedocument @iDoc OUTPUT, @FileContentsSELECT * INTO #JOBS FROM OpenXML(@iDoc, 'job/jobHeader', 2) WITH (version float, ProfileId int, jobNumber varchar(25), email varchar(100), dateFrom varchar(10), dateTo varchar(10), jobType varchar(1) )EXECUTE sp_xml_removedocument @iDoc |
 |
|
|
eyechart
Master Smack Fu Yak Hacker
3575 Posts |
Posted - 2005-06-02 : 18:06:53
|
| you aren't using unicode datatypes in your WITH schema declaration. -ec |
 |
|
|
cbeganesh
Posting Yak Master
105 Posts |
Posted - 2005-06-03 : 09:51:48
|
| you mean to change the columns datatype to ntext |
 |
|
|
|