Create new table from another in sql server

0

I'm doing this query :

CREATE TABLE nova_tabela AS
SELECT * FROM tabela_copiada;

I'm getting the following error :

  

Incorrect syntax near the keyword 'SELECT'

I already searched the syntax and I think it is correct. Can anyone help me?

    
asked by anonymous 09.01.2018 / 19:34

1 answer

2

The correct syntax is

SELECT colunas 
INTO tabelaNova 
FROM TabelaQueDesejaCopiar 
WHERE Condicao
  

SELECT ... INTO creates a new table in the default filegroup and inserts   in it the rows resulting from the query

Microsoft Docs

Your select would look like this:

SELECT * INTO nova_tabela FROM tabela_copiada
    
09.01.2018 / 19:38