• I know this is a few days old but I thought it would be good to expand on this a little:

    The W3C defines two technologies for "Transforming XML": SQLXML/XQuery and XSLT

    A limited version of XQuery is available in XML but, as arthurolcot mentioned, it would likely do the trick (especially if you are dealing with 4 simple columns). XML Transforms (XSLT) are the more elegant way to go IMHO but the only way to run XSLT is via SSIS or SQLCLR.

    On that note, if you go the SQLCLR route you can use mdq.xmltranform (a CLR written by Microsoft) to transform XML to HTML. You can also build an XSLT CLR from scratch but mdq.xmltransform has already been compiled and takes one minute to setup (no need to create a new DLL). I wrote a couple articles about how to do transforms in SQL Server. mdq.xmltransform will be slower than using XQuery but it will work and the code will be 99.9% portable. Doing the transforms using SSIS will perform butter (but will also require you to be comfortable with SSIS which not everone is).

    A few good sites about transforming XML using XSLT:

    http://w3schools.com/xpath/default.asp

    http://w3schools.com/xsl/default.asp

    http://www.xml.com/pub/a/2000/08/holman/index.html?page=5#sample1

    Edit: Added note about not needing to compile a dll for the CLR

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001