Home > SQL > About Temporary Table in SQL Server

About Temporary Table in SQL Server

Temporary table is one of the concept in SQL Server which help the developer in a great way. This tables can be created at runtime and can do the all kind of operation that one normal table can do.

Temporary table is just like normal table, we can create it at run time and have same kind of operation as in normal table.

Types of Temporary Table

1) Local (#,@)
2) Global (##)

1)      Local Temporary Table (#,@)

When temporary table name start with ‘#’ sing, then  temp tables are only available for the current connection. This table are destroyed automatically when the user disconnects  from instances. 

CREATE TABLE #MyTable 

    id INT, 
    name VARCHAR(20) 
)

2)      Global(##)

When temporary table name start with ‘##’ sing, then  temp tables are available permanently to all users. This table are destroyed when all user connections are closed, else user have to destroyed manually.

CREATE TABLE ## MyTable 

    id INT, 
    name VARCHAR(20) 
)

Normally Temporary is available in tempdb

Advertisements
Categories: SQL
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: