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
What is data set in report?
Explain active/passive and active/active cluster configurations?
hi, the following are the outputs of sp_spaceused and sp_tempdbspace sp_spaceused ------------ database size unallocated size tempdb 77752.95 MB 28026.99 MB sp_tempdbspace ------------- database size spaceused tempdb 77752.945312 1.007812 the unused space in sp_spaceused is nearly 28 Gb and in sp_tempdbspace is nearly 76 Gb cany any one explain about this output and why its giving different results.
How does the report manager work in SSRS?
What are the acid properties?
what data regions are and what are the different data regions?
Explain what are the restrictions while creating batches in sql server?
What are the recovery models for a database?
OPTIMIZATION OF SP,CURSOR,TRIGGERS
Difference Between ORDER BY Clause and GROUP BY Clause in SQL?
what type of index will get created after executing the above statement? : Sql server database administration
How do I perform an unattended install of sql server 2000?
Name the different type of indexes in sql?
Explain the functionalities that views support?
What is 4nf in normalization form?