• Thanks for the quick response.

    I have run it through the T-sql debugger in query analyser and it errors right at the FOR statement below when it tries to populate the cursor.

    I have isolated the create table for #Objects and the insert statements, then created the table, populated it, created the cursor and populated it in a seperate connection outside of the sproc and it works.

    The debugger boke at **ERROR** a few seconds

    --Use a cursor to step through the objects so we can reconstrunct them

    DECLARE crsObjects CURSOR LOCAL FAST_FORWARD

    **ERROR** FORSELECTobj.[DBId], obj.[ObjectId], obj.[Text], obj.XType

    FROM#Objects obj

    ORDER BYobj.[ObjectId], obj.[ColId]

    Is there anything else you would find useful to know?

    Thanks