Error on simple create table statement

Dom 951 Reputation points
2023-07-07T15:53:16.2566667+00:00

SQL Server 2016. Why is this simple Create Table statement invalid? Seems like it should be straight forward.

User's image

IntelliSense says

User's image

If this is a required parameter, which one do I choose and why?

SQL Server | Other
0 comments No comments
{count} votes

Answer accepted by question author
  1. Dan Guzman 9,411 Reputation points
    2023-07-07T16:01:48.2366667+00:00

    There is no CREATE TABLE AS(subquery) in SQL Server 2016 syntax. Instead, use SELECT INTO to create a new empty table based on the result set schema:

    SELECT *

    INTO dbo.djmdev03

    FROM dbo.datetable

    WHERE 1 = 2;

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.