Create a temporary table, #代表局部临时表, # #代表全局临时表. What is the specific meaning of local temporal tables and global temporary tables?
For example, it is clearer to look at the local temporary table, "New query", enter the following text:
After running, we execute input in this file: SELECT * from #tempTable, after execution can query the following data:
We also open a "new query", named it as a new query 2, in the new query 2 to execute the input: SELECT * from #tempTable, prompt as follows:
Modify the #temptable in the SQL statement to # #tempTable, follow the above method again, you will find that new query 2 no longer prompt for errors, can detect and create new query 1 the same results. Why?=> Local temporary tables are only visible in the current session, and global temporary tables are visible in all sessions.
Note that after you use the global temporary table, do not forget to drop table out of it. However, with local temporary tables, you can do this without doing this, and the local temporary tables created are automatically reclaimed at the end of the current session.
For detailed usage please refer to: http://www.cnblogs.com/shineqiujuan/archive/2008/11/13/1332657.html