Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

SQL statement error of "incorrect syntax near the keyword 'as'"

Posted on 2011-03-02
4
Medium Priority
?
341 Views
Last Modified: 2012-06-21
Why is this sql statement throwing an error of "incorrect syntax near the keyword 'as'" CREATE TABLE [TempTable] AS (Select * From [Direct_Construction] where [PID] = @LastPID)
Parameter of @LastPID is being supplied

0
Comment
Question by:WSU-CPD
4 Comments
 
LVL 32

Expert Comment

by:Ephraim Wangoya
ID: 35018888
What exactly do you want to do, Create a table then insert data into it
0
 
LVL 15

Accepted Solution

by:
derekkromm earned 500 total points
ID: 35018890
select * into [TempTable] from [Direct_Construction] where [PID] = @LastPID
0
 

Expert Comment

by:ricksteele
ID: 35018921
CREATE TABLE expects a set of column definitions.  Try this:

Select *
INTO [TempTable] 
From [Direct_Construction] 
where [PID] = @LastPID

Open in new window


Not sure off the top of my head if you can do this with Select *, you might have to pick some columns.
0
 

Author Closing Comment

by:WSU-CPD
ID: 35018927
Thank you!  I have been beating my head against the wall on this one.  Knew it was simple.  Thanks!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

916 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