Skip to content

Incorrect invalid syntax error when creating a table with an inline index that includes columns #19421

Open
@kwdowns

Description

@kwdowns
  • MSSQL Extension Version:1.31.1
  • VSCode Version:1.100.1
  • OS Version:Windows_NT x64 10.0.26100

Steps to Reproduce:

  1. Open a new .sql file
  2. Paste the following create table statement
CREATE TABLE Example(
  Id INT NOT NULL IDENTITY(1,1) PRIMARY KEY,
  Foo VARCHAR(50) NOT NULL,
  Bar VARCHAR(50) NOT NULL,
  INDEX IX_Example_Foo
    NONCLUSTERED (Foo) 
    INCLUDE (Bar)
)

Image

This syntax has been valid since SQL Server 2016

https://learn.microsoft.com/en-us/sql/t-sql/statements/create-table-transact-sql?view=sql-server-ver16#full-syntax

<table_index> ::=
{
    {
      INDEX index_name [ UNIQUE ] [ CLUSTERED | NONCLUSTERED ]
         ( column_name [ ASC | DESC ] [ ,... n ] )
    | INDEX index_name CLUSTERED COLUMNSTORE [ ORDER (column_name [ , ...n ] ) ]
    | INDEX index_name [ NONCLUSTERED ] COLUMNSTORE ( column_name [ ,... n ] )
    }
    [ INCLUDE ( column_name [ ,... n ] ) ]
    [ WHERE <filter_predicate> ]
    [ WITH ( <index_option> [ ,... n ] ) ]
    [ ON { partition_scheme_name ( column_name )
         | filegroup_name
         | default
         }
    ]
    [ FILESTREAM_ON { filestream_filegroup_name | partition_scheme_name | "NULL" } ]
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions