Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 xml error

Author  Topic 

cbeganesh
Posting Yak Master

105 Posts

Posted - 2005-06-01 : 12:24:16
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 : 01:10:09
humm... looks like I've seen this post in another category.. anyways to make your code clean, I suggest that create a stored procedure that will execute the sp_xml_preparedocument, and this stored procedure call it in the .NET passing a NTEXT Datatype to its parameter.


CREATE PROCEDURE [dbo].[SampleProc]
@xmlData AS ntext
AS
BEGIN
DECLARE @hDoc int
EXEC sp_xml_preparedocument @hDoc OUTPUT, @xmlData
INSERT INTO YourTable (
WSCode,
CustType
)
SELECT *
FROM OPENXML(@hDoc, '/Map', 2)
WITH (

WSCode nvarchar(100) 'WSCode',
CustType char(2) 'CustType'
)
EXEC sp_xml_removedocument @hDoc
END
GO


"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
Go to Top of Page

cbeganesh
Posting Yak Master

105 Posts

Posted - 2005-06-02 : 09:58:08
Yes that was me who posted in another catgeory. Nobody seems to reply in this category. Anyhow I have the used the same type of code in the stored procedure
Go to Top of Page
   

- Advertisement -