Home Forums SQL Server 2005 Development Can a temporary table created with an execute statement survive that statement? RE: Can a temporary table created with an execute statement survive that statement?

  • Not sure what would be so "unstable" or undesirable about it. It works the way it's supposed to. The global table variable doesn't seem to buy you much IMO.

    The procedure:

    - Create the temp table with the columns you know in the "main" statement.

    - run the 'alter table' command in one EXEC statement to add the variable columns

    - then, run the INSERT INTO statement in a second EXEC statement with the new columns.

    Once you're done - the original table will have all of the columns AND the data you want.

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?