Solved

Difference between SELECT INTO & SELECT INTO#

Posted on 2002-03-19
3
186 Views
Last Modified: 2006-11-17
Hi,

I am taking over an application using SQL Server but I am not that fluent with it...

There is the SQL command:
Select TUSERS.* into #TNEWTABLE from TUSERS where uid=1

but what is the difference with
Select TUSERS.* into TNEWTABLE from TUSERS where uid=1

Thanks for your help,
Christophe
0
Comment
Question by:FraggleRock
3 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 100 total points
ID: 6879620
The first one create a temporary table (in tempdb database), the second one a local table (in your current database). The first one will be dropped when you connection ends, the second one remains...

CHeers
0
 
LVL 2

Expert Comment

by:Carlovski
ID: 6879624
The syntax #tablename refers to a temporary table.
So the first statement creates a table which will only last for the lifetime of the connection, whereas the second will create a permanent table.
You may also see ##tablename, which is a global temporrary table, where all users can access the table, but will be deallocated when the last user to access it disconnects.

Regards,
Carl
0
 
LVL 1

Author Comment

by:FraggleRock
ID: 6879651
Brilliant!
Thanks very much.

Christophe
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
I have a large data set and a SSIS package. How can I load this file in multi threading?
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

823 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question