Drop a temp table

Well folks we know that temp tables are closed when the user closes his/her session. In fact, BOL explicitly states :

“Local temporary tables are visible only to their creators during the same connection to an instance of SQL Server as when the tables were first created or referenced. Local temporary tables are deleted after the user disconnects from the instance of SQL Server.”

Now here is the problem. One of our users complained that he had disconnected from SQL Server. When he came back, the temp table that he had created was still present. It was preventing him from running a query successfully.

Note that though he disconnected from the instance and then re-connected, the temp table was still present.

We could see that his sessions were still active in many databases. After getting his permission, we proceeded to close all his sessions.

As expected, it dropped the temp table also.

Hope this helps!

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.