• If you are interested in using OPENXML I strongly suggest that you get hold of a copy of SQL Server XML Distilled. Why you may ask, well I wrote the OPENXML chapter. It covers, the pros and cons of element and attribute centric documents. Performance of using OPENXML relating to document size, attributes, namespaces.

    There are lots of gotchas to be wary of, type casting, nulls, case sensitivity, use of complex xpath.

    I also investigate the memory issue, its not as cut and dried as the 1/8th statement suggests, and generally depends on available memory at startup

    You can't pass in a filename, but in 2005 you can read the contents of a file into an xml variable and then use that.

    Passing the XML document to the SQL server is just the same as passing any other text. exec up_myXMLProc '<root><element1></element1> ....</root>', No clean up is neccesary except the use of sp_xml_removedocument, which should be called after every openxml call.

    As for the benefits, the one is the saving of hierachical data, you only have to make one SP call rather than one for the parent and one for each child. These can be batched up which is why in testing both ways work out to be pretty much the same.

    In 2005 the parser has been updated so you can use more xpath functions, in addition you can use xquery.

    So lots of good things.


    Simon Sabin
    SQL Server MVP

    http://sqlblogcasts.com/blogs/simons