Skip to content
Advertisement

Create table from a table in SQL Server

Below is the query I tried to execute in SQL Server:

CREATE TABLE List 
AS 
    (SELECT * FROM counts)

I get this error:

Msg 102, Level 15, State 1, Line 1
Incorrect syntax near ‘(‘

I did some research on google to understand and isolate the error, but, failed to do so. Could anyone please help me understand the error. Thank you

Advertisement

Answer

SQL-Server’s syntax to create a table from a query is by adding an into clause:

SELECT *
INTO   list
FROM   counts
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement