Temp tables

  • I am doing some testing and need to detect the existence of a temporary (#) table that I created.

    I tried the format you get when you generate a drop script for a table using Query Analyzer, but it does not work for temporary tables.

    Would anyone have a test for the existence of a temp table?

    Thanks!

  • Tom,

    # (temp) tables will be stored in TempDB database & will be Alive for the current session (SPID) only. Once you close the session, it will be dropped from the DB automatically.

    Within the instance, you can check whether the table is available using the following query:

    SELECT * FROM tempdb.sys.objects WHERE name like '%table_name%'

    Cheers,

    Suresh

    Suresh

  • Tom Carnahan (1/20/2009)


    I am doing some testing and need to detect the existence of a temporary (#) table that I created.

    I tried the format you get when you generate a drop script for a table using Query Analyzer, but it does not work for temporary tables.

    Would anyone have a test for the existence of a temp table?

    Thanks!

    Jeff finds it out nicely in his post.

    http://www.sqlservercentral.com/Forums/Topic439174-8-1.aspx



    Pradeep Singh

  • Suresh and Pradeep ... thanks for the help!

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply