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

create temp table with select statement

Posted on 2009-04-01
4
478 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
  • 3
4 Comments
 
LVL 31

Accepted Solution

by:
RiteshShah earned 400 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 400 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 100 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

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
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.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

861 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