If I convert a nvarchar
string containing a full line break (\r\n) to XML, then when converting back, I find that instead of \r\n the resulting string contains only \n.
Is there a server or connection option controlling this behaviour?
declare
@ln nvarchar(2) = char(13)+char(10)
declare
@str nvarchar(max) = '<x>qwe '+@ln+' asd</x>'
print @str
print charindex(@ln, @str) -- found
/* output: 8 */
-- convert to xml
declare @xml xml = convert(xml, @str)
-- convert back to str
set @str = convert(nvarchar(max), @xml)
print @str
print charindex(@ln, @str) -- not found
/* output: 0 */
print charindex(char(13), @str) -- not found
/* output: 0 */
print charindex(char(10), @str) -- found
/* output: 8 */