Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

What is a SQL Server Temporary Table?

Answer Posted / mohammadali.info

Temporary tables are a useful tool in SQL Server provided to allow for short term use of data. There are two types of temporary table in SQL Server, local and global.

Local temporary tables are only available to the current connection to the database for the current user and are dropped when the connection is closed. Global temporary tables are available to any connection once created, and are dropped when the last connection using it is closed.

Both types of temporary tables are created in the system database tempdb.

Temporary tables can be created like any table in SQL Server with a CREATE TABLE or SELECT..INTO statement. To make the table a local temporary table, you simply prefix the name with a (#). To make the table a global temporary table, prefix it with (##).

-- Create a local temporary table using CREATE TABLE
CREATE TABLE #myTempTable
(
DummyField1 INT,
DummyField2 VARCHAR(20)
)

-- Create a local temporary table using SELECT..INTO
SELECT
age AS DummyField1,
lastname AS DummyField2
INTO #myTempTable
FROM DummyTable

To make these into global temporary tables, just replace (#) with (##)

Is This Answer Correct ?    15 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Do you know what is similarity and difference between truncate and delete in sql?

1061


What is the difference in accessing db between sql server vs sql azure?

174


Due to some maintenance being done, the sql server on a failover cluster needs to be brought down. How do you bring the sql server down?

1380


Is a primary key unique?

1035


What are the new scripting capabilities of ssms? : sql server management studio

1117


explain declarative management framework (dmf) in sql server 2008?

1042


What are indexes in ms sql server?

1114


Where views are stored in sql server?

1027


How do you set a trace flag in sql server?

1086


is there a column to which a default can't be bound? : Sql server database administration

1049


What is change data capture (cdc) in sql server 2008?

1078


What is normalization? Describe its different types.

1151


What is the bookmark lookup and rid lookup?

1034


What is a join in sql?

1152


What do you understand by integration services in sql server?

998