• Thanks for that. Though I should have come back to say I was able to optimise it by calling it with 20k chunks and putting them all back together myself... at about 1 minute per query but liveable.

    However, then I discovered that neither SSMS nor SQLCMD were built to handle rows that exceed a megabyte of raw text data. Even pulling it back as XML format (which is what Microsoft recommends in this situation) was causing issues with things being truncated... and then saving it into a text file and trying to open it in notepad or SSMS? Even more problems.

    Now I understand why stuff like SQL Data Compare (3rd party product) do it in few-thousand char wide column chunks with UPDATETEXT. Unfortunately, we don't own the scripting versions that might let me automate it.

    Anyhow I was using it in combination with another open source stored procedure that generates INSERT statements (with this plugged in to do the IMAGE bits). It'll only take a bit more pain for me to finish it up, and hopefully I can give it back without too much arm bending from the company.