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'
Already researched the syntax seems to me correct. Someone can help me?
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'
Already researched the syntax seems to me correct. Someone can help me?
2
The correct syntax is
SELECT colunas
INTO tabelaNova
FROM TabelaQueDesejaCopiar
WHERE Condicao
SELECT... INTO creates a new table in the default file group and inserts on the lines resulting from the consultation
Your select would look like this:
SELECT * INTO nova_tabela FROM tabela_copiada
Complementing, when you want to create the new table with the same structure but without data, just use restriction that returns false; for example: WHERE 1 = 0
Browser other questions tagged sql sql-server
You are not signed in. Login or sign up in order to post.
temporary or physical table ?
– Marco Souza
@Leonardosilva The construction
CREATE TABLE ... AS (SELECT ... FROM ...)
works in some database managers but not in SQL Server.– José Diz