• I would run the inserts one at a time and see if they throw errors. Either that or put in some dummy print statements to see which insert/select statement is causing the error. Just remove them before sending this to production.

    Since this is more a T-SQL question than a reporting question now, you might want to post the query there with some table definitions etc. You're much more likely to get a good answer.

    Pieter