• Jason

    Looks like you have done some good work.

    However, I tried to run the stored procedure and got....

    Msg 6841, Level 16, State 1, Procedure who4, Line 28

    FOR XML could not serialize the data for node 'processing-instruction(definition)' because it contains a character (0x0000) which is not allowed in XML. To retrieve this data using FOR XML, convert it to binary, varbinary or image data type and use the BINARY BASE64 directive.

    I will try and debug if/when I get time, If any anyone else has a solution already then tell me!