Solved

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

Posted on 2011-03-02
4
325 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:ewangoya
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 125 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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

So every once in a while at work I am asked to export data from one table and insert it into another on a different server.  I hate doing this.  There's so many different tables and data types.  Some column data needs quoted and some doesn't.  What …
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

820 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