0

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!

mitchmitch24
  • 385
  • 1
  • 7
  • 20

2 Answers2

3

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;
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
0

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

Use MyDatabase
Go

SELECT * INTO TestTable FROM dbo.MyTable
GO
Pawan Kumar
  • 1,991
  • 10
  • 12
  • 3
    Not just Oracle. CTAS (Create Table As SELECT...) is supported by most RDBMs, including Azure. Not sure why it hasn't been introduced into SQL Server yet. Maybe vNext. – Eric Brandt Feb 22 '18 at 16:39