Saturday, March 7, 2015

drop temp tables

In addition to Olaf's, if you create temp table in two different sessions, you will find the 2 #test in the TempDB.sys.tables.



CREATE TABLE #test (id int);


Either the different object_ids or the "same" names indicate they are different temp tables. The same named local temp tables created in different sessions are traced with a 12 suffix in the tempdb.sys.tables. That's why when creating temp tables, maximum length can be of 116 characters only, while creating a table, the maximum is 128.


The fragment referenced from the BOL



  • You can create local and global temporary tables. Local temporary tables are visible only in the current session; global temporary tables are visible to all sessions.

  • All local temporary tables are dropped automatically at the end of the current session.


You can read more from the below link.

http://ift.tt/1Brib7d


If you have any question, feel free to let me know.




Eric Zhang

TechNet Community Support




No comments:

Post a Comment