Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Difference between SELECT INTO & SELECT INTO#

Posted on 2002-03-19
3
194 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 143

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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
backup job space check 4 43
SSRS - Date Report Options 2 28
SQL Quer 4 21
RESTORE MASTER DATABASE -- NOW 2 19
Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

856 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