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?

  • Jeff:

    What are the circumstances for that? When I run the following query it get the commented results:

    use tempdb

    go

    select name as before from sysobjects where type = 'U'

    exec ( 'create table #what(a int) select name as during from sysobjects where type = ''U'' ')

    select name as after from sysobjects where type = 'U' order by name

    /* -------- Sample Output: --------

    before

    ------------------------

    during

    --------------------------------------------------------------------------------------------------------------------------------

    #what_______________________________________________________________________________________________________________000000000005

    after

    ------------------------

    */