Error running a simple sql command
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 keywor开发者_开发技巧d '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.
Try
Select * Into TempPosition
From Position
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
create table tempPosition as select * from Position;
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
精彩评论