Friday, March 23, 2012

Problem with sp_OAMethod 'WriteLine for special characters

I use sp_OAMethod 'WriteLine' to write some VARCHAR data into a file. The problem is, that when the VARCHAR data contains special characters like "?ü?", they not not correctly written and the file, if its a xml file is invalid.

VARCHAR data is "Datei abholen\Dateiname prüfen"

Statements are:

SET @.XMLComment = '<!-- TestCase :' + @.param_TestCase + ' -->'

execute @.OLEResult = sp_OAMethod @.FileID, 'WriteLine', Null, @.XMLComment

Output is: <!-- TestCase Datei abholen\Dateiname pr?->

Is there any workaround to have it read/write special characters correctly in the file?

Any help is appreciated.

Thanks.

Added later:

I found a way to do the same with bcp, but also that utility has problems with "??ü" characters.

Try passing the charecters by using the CHAR function to the @.XMLcomment variable.

For instance

CHAR(228)

would produce ?

No comments:

Post a Comment