| Start |
|---|
| Dropping temp tables Temp tables must have unique IDs (within the session, for local temp tables, or within the server, for global temp tables). Trying to create a table using a name that already exists will return the following error: If your query produces temp tables, and you want to run it more than once, you will need to drop the tables before trying to generate them again. The basic syntax for this is: Trying to execute this syntax before the table exists (e.g. on the first run of your syntax) will cause another error: To avoid this, you can check to see if the table already exists before dropping it, like so: |
Local Temp Table After executing all these statements if we close the query window and open it again and try inserting and select it will show an error message |
Global Temp Table Note: These are viewable by all users of the database, irrespective of permissions level. RemarksTemporary Tables are really very helpful. The table can be created at runtime and can do all operations which are done in a normal table. These tables are created in a tempdb database. Used when ? Thus increases the performance. |
Read Article
https://develop.horje.com/learn/1434/reference