October 14, 2009 at 3:25 am
I would Like to create a temporary table to store data to do some testing. How can I create a temp table? How do I go about doing it?
Thanks.
October 14, 2009 at 3:27 am
October 14, 2009 at 3:29 am
Temporary Tables
You can create local and global temporary tables. Local temporary tables are visible only in the current session, and global temporary tables are visible to all sessions. Temporary tables cannot be partitioned.
Prefix local temporary table names with single number sign (#table_name), and prefix global temporary table names with a double number sign (##table_name).
SQL statements reference the temporary table by using the value specified for table_name in the CREATE TABLE statement, for example:
CREATE TABLE #MyTempTable (cola INT PRIMARY KEY);
INSERT INTO #MyTempTable VALUES (1);
--------------------------------------------------------------------------------------
[highlight]Recommended Articles on How to help us help you and[/highlight]
[highlight]solve commonly asked questions[/highlight]
Forum Etiquette: How to post data/code on a forum to get the best help by Jeff Moden[/url]
Managing Transaction Logs by Gail Shaw[/url]
How to post Performance problems by Gail Shaw[/url]
Help, my database is corrupt. Now what? by Gail Shaw[/url]
October 14, 2009 at 7:15 am
Or to create a temp table pre populated with data from existing table
select col1, col2
into #temp
from table1
October 14, 2009 at 7:29 am
zy-eliz (10/14/2009)
I would Like to create a temporary table to store data to do some testing. How can I create a temp table? How do I go about doing it?Thanks.
You can populate a temp table directly from a permanent table just using...
SELECT * INTO #country FROM [COUNTRY]
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply