I have a method that is taking vales directly from the database, building a string of xml and then writing the xml to a file.
This is fine until I get special characters eg "'", "<", "&" etc.
Does anyone know of something in Sql Server that would allow me to encode the values as i select them; for example;
select encode(service_status) from myTable
Thanks.
Best Answer
Use
FOR XML
clause.It can build
XML
from multiple values automatically:If you just want to encode an existing value, use: