Solved

Difference between SELECT INTO & SELECT INTO#

Posted on 2002-03-19
3
166 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
Comment Utility
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
Comment Utility
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
Comment Utility
Brilliant!
Thanks very much.

Christophe
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
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.

771 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now