how to find owner(SPID) of the temp tables

  • Dear All

    In temp db i find many temp tables created. I would like to know which SPID has created these.

    Is there a way to check this?

    Regards

    Krishna1

  • Not sure we can achive this. Better name your temptable with SPIDs.

    sys.dm_db_session_space_usage will give you some details about temp tables' usage.

  • I am not creating the temp tables. but i still see few created automatically. Hence wahanted to know from where are they getting created

  • Short of profiling the instance, I don't think you can tell which session created which table. You can see the temp space that each session uses with the sys.dm_db_session_space_usage DMV.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • I suppose you COULD write a server level trigger to append the SPID to the table extended properties. Not sure how useful that would be.

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

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