0

I am using Microsoft SQL Server 2008. My version of Server Management Studio is 2014. I am attempting to create a table in a database I imported from a Microsoft SQL Server 2005.

Here is my code:

CREATE TABLE testTableNicks AS (    
    SELECT *
    FROM Person
    WHERE name LIKE'%nick%'
);

I get following error:

Incorrect syntax near (

Further testing: I get the same error when I try just creating a table using

  • Create table testTableNicks
  • Create table 'testTableNicks'
  • Create table [testTableNicks]

closed as off-topic by Michael Green, Paul White Oct 4 '15 at 11:12

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Too localized - this could be because your code has a typo, basic error, or is not relevant to most of our audience. Consider revising your question so that it appeals to a broader audience. As it stands, the question is unlikely to help other users (regarding typo questions, see this meta question for background)." – Michael Green, Paul White
If this question can be reworded to fit the rules in the help center, please edit the question.

2

INSERT INTO SELECT inserts into an table that already exists.

SELECT INTO put data in a table that you will create in the same action ( whitout the need to create column by column.

You should use something like this:

INSERT INTO...SELECT

CREATE TABLE Table_Name 
   (
       name varchar(255)
    )
GO

INSERT INTO Table_Name
  SELECT name
   FROM some_Database;
 GO

SELECT INTO

SELECT Field 
   INTO Table_name --This table will be created now
FROM Some_Database;
GO

Not the answer you're looking for? Browse other questions tagged or ask your own question.