In my dataset, I have a field which stores text marked up with HTML. The general format is as follows: <html><head></head><body><p>My text.</p></body></html> I could attempt to solve the problem by doing the following: However, this is not a strict rule as some …
Tag: xml
XML Schema totalDigits/fractionDigits vs. SQL precision/scale
I’d like to find out the correspondence between XML Schema totalDigits/fractionDigits and SQL numeric precision/scale. 1) Assume we have the following simple type: How would I represent it in SQL? Let’s assume HSQL dialect (it does not matter much). I’m interested in the most restrictive SQL…
SQL Server: Replace invalid XML characters from a VARCHAR(MAX) field
I have a VARCHAR(MAX) field which is being interfaced to an external system in XML format. The following errors were thrown by the interface: mywebsite.com-2015-0202.xml:413005: parser error : …
XML to SQL – Selecting multiple nodes with the same name
I have working code that can select a few values from an XML file. The problem is that I have multiple nodes with the same name. Here is a snippet of the XML:
How to count occurrences of a node in SQL XML?
I am trying to do a count on the number of occurrences of the “Colors” node but have been so far unsuccessful. Below is what I have tried so far. If I have the following logic: I get the following error: Msg 2389, Level 16, State 1, Line 50 XQuery [value()]: ‘value()’ requires a single…
SQL – Blank default namespaces
I have a relation which has an XML column storing data in the following structure 04-12-2012 &…
Carriage return symbol is removed from XML using OPENXML
It looks like SQL Server removes r characters when parsing XML. So when my stored procedure receives values in xml for saving, all line breaks are represented as n instead of rn. Is there any way …
SQL and escaped XML data
I have a table with a mix of escaped and non-escaped XML. Of course, the data I need is escaped. For example, I have: <…
Use a LIKE statement on SQL Server XML Datatype
If you have a varchar field you can easily do SELECT * FROM TABLE WHERE ColumnA LIKE ‘%Test%’ to see if that column contains a certain string. How do you do that for XML Type? I have the following …