Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2011-03-02
4
Medium Priority
?
336 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
[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
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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

When writing XML code a very difficult part is when we like to remove all the elements or attributes from the XML that have no data. I would like to share a set of recursive MSSQL stored procedures that I have made to remove those elements from …
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

688 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