Reputation: 3978
I am very tired and maybe I am missing something obvious.
I got this error:
Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'select'.
Running this simple command
create table tempPosition select * from Position;
Any idea?
Thanks
P.S. sql server 2008
EDIT
my apologies I forgot a fundamental piece of information, the table has an primary key that auto-generate the id. It was that column that was causing the problem. Using the full list of columns (omitting the primary key) solved the problem. Thanks for your help.
Upvotes: 0
Views: 70
Reputation: 1234
For SQL Server the format of the queries are as follows:
-- Insert And Create Table
SELECT [list items] INTO TableOut FROM TableIn
-- Create The Table Only
SELECT [list items] INTO TableOut FROM TableIn WHERE 0=1
Upvotes: 0
Reputation: 27933
This creates a temporary table (good for the life of your connection, then deleted when you disconnect) containing all the contents of Position.
SELECT *
INTO #tempPosition
FROM Position
Upvotes: 0