2

In SSMS I see 7 temporary tables, all with names like dbo.#0876219E. When I end my connection and come back in, they are still there.

I'm not able to query them or get properties on them. I get errors.

How do I find their source, purpose and what they contain?

Is there a particular system sp that gives info on temp tables -- haven't been able to immediately find one.

1
  • If you restart the SQL service, are they still there? Commented Nov 22, 2010 at 22:53

2 Answers 2

2

Temp tables with such names (#, then 8 hex digits) are the temp tables that back table variables - declare @boris table (...)

They'll exist as long as the batch that introduced them continues to run. On my lightly loaded dev server, I can see ~30 of them, so I'm guessing there are some which are used/created by SQL Server itself - or possibly by SSMS.

Sign up to request clarification or add additional context in comments.

Comments

0

Temp tables in SQL Server are perfectly normal. They are usually dropped when the database service is restarted (along with TempDB in which they are stored).

If you provide us with more context to where you see these temp tables, that would be helpful.

EDIT:

This quote is taken from the following forum post, which summarises the role of tempdb nicely:

tempdb is used for sorting, aggregation, distincts, unions, temp tables and table variables, row versioning. It can also be used for index building.

Oh and cursors

2 Comments

SSMS-Databases-System Databases-Tempdb-Tmporary Tables Lists seversal such as dbo.#0876219E, dbo.676A338E, etc. I can't tell what created these or what the contain; good to know they're normal.
I've updated my answer with a nice summary of what tempdb is used for. There are many thousands of sources, including SQL Books Online, but I like this summary.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.