Use ampersand in CAST in SQL
The following code snippet on SQL server 2005 fails on the ampersand '&': select cast('<name>Spolsky & Atwood</name>' as xml) Does anyone know a workaround? Longer explanation, I need to update some data in an XML column, and I'm using a search & replace type hack by casting the XML value to a varchar, doing the replace and updating the XML column with this cast. select cast('<name>Spolsky & Atwood</name>' as xml) A literal ampersand inside an XML tag is not allowed by the XML standard, and such a document will fail to parse by any XML parser. An XMLSerializer() will output the ampersand HTML