How come we will know how many temp tables are created in that session

  • Dear all,

    I am working in SQL Server 2008,

    I want to know how many #temp tables are created in that session and what are the names of the temp tables?

    Regards,

    Ram

  • This works ok in 2005

    select *

    from tempdb..sysobjects

    where name like '#tablename%'

    or just use

    where name like '#%'

  • The method specified will not tell you what tables are only for this session..

    Also, I'm curious what you need this information for, once the session ends they will be dropped by the system anyway even if you don't do anything.. And if you are doing your own cleanup you should know their names..

    CEWII

  • Thanks it works fine in Sql 2008 too.

    Why i need this is, i have a long procedure which has multiple temp tables finally i need to drop those tables.

    So i need to find all the temp tables. now it is very easy to me.

    thanks a lot!

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

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