OPENXML and non-ascii characters

  • This code fails with an XML Parse error because of the French character, can anyone tell me how to make it work? Thanks.

    DECLARE @idoc int

    EXEC sp_xml_preparedocument @idoc OUTPUT, '<Name>Labbé</Name>'

    SELECT Name FROM OPENXML (@idoc, '/Name') WITH (Name char(10) '.')

    EXEC sp_xml_removedocument @idoc

  • This is a little out of my area, but I think you need to handle the double-byte character in a nchar field rather than plain old, char.

  • Yep, nvarchar does it. Thanks

  • I was too quick there. Using nvarchar fixed the first problem, but now I have halved the possible size of my parameter. My xml in some cases is larger than 4,000 bytes and the proc fails with xml parser error, presumably cos the xml is being truncated.

    Is it possible to pass text parameters to a proc? Or would I need to use some other method, like using ADO on the client to insert the xml into a table using text functions?

  • Answered my own questions after a bit of rtfm (sorry for being so lazy). Didn't know a SP could have ntext as a parameter!!

  • If you  use <!CDATA> for any data it should work.

    Leah Kats

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply