mitchmitch24
mitchmitch24

Reputation: 383

Microsoft SQL Server Error: "Incorrect syntax near keyword Select"

Unsure what syntax the error is referring to at this statement :-

Use MyDatabase
CREATE TABLE TestTable 
    AS (SELECT * FROM dbo.MyTable);

Any help is appreciated!

Upvotes: 0

Views: 2920

Answers (2)

Pawan Kumar
Pawan Kumar

Reputation: 2011

You need to use like below. The one you are using is Oracle syntax.

Use MyDatabase
Go

SELECT * INTO TestTable FROM dbo.MyTable
GO

Upvotes: 0

Gordon Linoff
Gordon Linoff

Reputation: 1269493

The dbo suggests that you are using SQL Server. The syntax error is that this syntax is not supported.

The equivalent syntax in SQL Server is:

SELECT *
INTO TestTable
FROM dbo.MyTable;

Upvotes: 3

Related Questions