Differences Between Temporary Table and Global Temporary Table in SQL Server

Hello to everyone,

In this article, I will talk about the difference between temporary tables and global temporary tables in SQL Server.

  1. Temporary tables use the odd # sign, while global temporary tables use the double ## sign.
  2. In SQL Server, temporary tables can only be accessed from their environment. If we want the table to be accessed from other environments, we must define it as global.
  3. The way temporary tables and global temporary tables are created are the same, except for the hash.
  4. Data in both tables are kept in tempdb.
  5. Adding, deleting etc. can be done on the created temporary tables as if adding and removing from a normal table. operations such as However, these tables are deleted when logout or SQL Server is stopped. Apart from this, tables can also be deleted with the “drop” command.
  6. Temporary tables are valid on the connections that the user who created the table used to create it. The table is automatically deleted as soon as the user closes the connection. In global temporary tables, once defined in a link, they can be used in all users and links like regular tables.

Good luck to everyone in business and life.

82 Views

Yavuz Selim Kart

I try to explain what I know in software and database. I am still improving myself by doing research on many programming languages. Apart from these, I am also interested in Graphic Design and Wordpress. I also have knowledge about SEO and Social media management. In short, I am a determined person who likes to work hard.

You may also like...

Don`t copy text!