?
Solved

create temp table with select statement

Posted on 2009-04-01
4
Medium Priority
?
505 Views
Last Modified: 2013-12-07
Hi Expert,

Why it does'nt work

CREATE TABLE #temCity1 AS SELECT * into #temCity FROM tblCity

Thanks in advance
0
Comment
Question by:dshi15
[X]
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
  • 3
4 Comments
 
LVL 31

Accepted Solution

by:
RiteshShah earned 1600 total points
ID: 24040334
emps is original table and #t is temp

select * into #t from emps
 
select * from #t

Open in new window

0
 
LVL 31

Assisted Solution

by:RiteshShah
RiteshShah earned 1600 total points
ID: 24040362
dont use CREATE table, don't need it, just use

SELECT * into #temCity FROM tblCity
0
 
LVL 39

Assisted Solution

by:BrandonGalderisi
BrandonGalderisi earned 400 total points
ID: 24040364
RiteshShah's method is correct.

Here's a post we have over at http://SQLServerNation.com explaining how to use select/into.

http://sqlservernation.com/blogs/tipweek/archive/2009/02/23/select-into.aspx
0
 
LVL 31

Expert Comment

by:RiteshShah
ID: 24040381
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

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…
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
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.
Viewers will learn how the fundamental information of how to create a table.
Suggested Courses

800 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