In SQL Server 2014, I try to add an XML element with an attribute (that contains a carriage return) using the 'modify' method on the XML datatype. The carriage returns gets removed - why is that?
Example:
declare @xmldata xml
select
@xmldata = '<root><child myattr="carriage returns 
 are not a problem"></child></root>'
set
@xmldata.modify('insert <child>modifying text with carriage returns works
ok</child> after (//child)[1]')
set
@xmldata.modify('insert <child myattr="but not
attribute values... why is that?"></child> after (//child)[2]')
select @xmldata
Result:
<root>
<child myattr="carriage returns 
 are not a problem" />
<child>modifying text with carriage returns works
ok</child>
<child myattr="but not attribute values... why is that?" />
</root>