• While it might seem a great idea to use XML to pass large rowsets to the database in a single hit. It is certainly easy to write the Stored Procedures. In reality XML processing in SQL Server does not perform, often negating the benefits of reduced round trips.

    This is well documented elsewhere but

    XML processing creates large structures in memory

    sp_xml_preparedocument grabs a flat eighth of your server's memory that is not released until sp_xml_removedocument is called. This is a real problem in production.

    Is CPU intensive in both intensity and duration.

    Do not use a WHERE clause on your OPENXML, that is a non-sargeable query.

    Filter after transferring to your temp table or filter while constructing the XML.

    If you must use XML, access it only once and pass the results into a temporary table.

    Other options for mass data transfer include

    String parsing, with care, this performs.

    Many SP parameters, this is not pretty, but performs exceptionally well on the server side. The trick is to retain code maintainability by constructing your SP using metacode at upgrade time, you only need a couple of loops, one to create the variable sets and one to generate the UNION ALL statement to insert them into a temp table.

    The above is the result of long, and bitter, experience!