• I guess I can't help on the error because the stored proc works fine for me. Your going to have to breakdown the proc by creating some variables and running the code in the proc instead of the CREATE PROCEDURE itself.

    The reason why you can't see the #Directory or #eq_Staging tables from the stored procedure is because they're Temp Tables. You can't see them outside of the scope of the stored procedure.

    Running the code to create the #Directory table will create the table in TempDB and you can actually see it but you might not be able to see its content in the object explorer because that constitutes a change in scope that hides the contents. Only the original session can see the contents.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)