How to create temporary SQL table

How to create temporary SQL table


How to create temporary SQL table? Just look at below CREATE TABLE statement.

CREATE TABLE #tempTable (
ID int,
Name char(30) )

As you can see, temporary SQL table will have a pound sign (#) in front of the table name. This is a temporary table in SQL server. It is only visible to the current session. This temporary SQL table will be dropped if the current session is closed.

There is another temporary table which is called global temporary table. It can be created by using 2 pound signs (##). This global table is visible to all the SQL connection on that server. When you create it, everyone else can see this table. However, this global table is seldom used in SQL server.