Reproduction issue, SQL code:
CREATE TABLE dbo.FooTable(SomeString NVARCHAR(100));
INSERT INTO dbo.FooTable(SomeString)
VALUES('Degree symbol is °');
DECLARE @Code NVARCHAR(4000) = N'BCP "SELECT (SELECT SomeString FROM dbo.FooTable FOR XML PATH(''Foo''), ROOT(''BAR''), TYPE )" QUERYOUT "F:\Output\File.XML" -c -C RAW -T ';
EXEC xp_cmdshell @Code;
DROP TABLE dbo.FooTable;
It creates a file with the following contents:
<BAR><Foo><SomeString>Degree symbol is °</SomeString></Foo></BAR>
Such files are not recognized as valid XML files using Internet Explorer and Firefox (Chrome gives an error error on line 1 at column 23: Encoding error). If I open them using Notepad and save it as Unicode (small end), it opens and is checked.
Update:
changing the bcpparameters -T -w -r -tseems to make XML valid for most XML users, but not for Internet Explorer.
source
share