Difference between SELECT INTO & SELECT INTO#

Posted on 2002-03-19
Last Modified: 2006-11-17

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,
Question by:FraggleRock
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
LVL 143

Accepted Solution

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...


Expert Comment

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.


Author Comment

ID: 6879651
Thanks very much.


Featured Post

Free Webinar: AWS Backup & DR

Join our upcoming webinar with experts from AWS, CloudBerry Lab, and the Town of Edgartown IT to discuss best practices for simplifying online backup management and cutting costs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Throw Error 7 32
Change this SQL to get all nodes 3 36
Regarding Disk IO 3 42
SQL syntax question 6 38
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…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

740 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