Skip to content

ALTER TABLE DROP COLUMN statements in TSQL fail if dropping multiple columns #6494

@ibeltran

Description

@ibeltran

Search before asking

  • I searched the issues and found no similar issues.

What Happened

I linted an ALTER TABLE DROP COLUMN statement with 2 columns and sqlfluff returned Found unparsable section

Expected Behaviour

When running parsing or linting on ALTER TABLE DROP COLUMN statements, properly formatted/written statements that list multiple columns should pass linting and parsing

Observed Behaviour

Parsing fails on the second column in the list, but passes if I only drop one column. However, this statement works in SQL Server without issue, and is valid according to SQL Server documentation

How to reproduce

Used SQL (drop_columns.sql)

ALTER TABLE table_name
DROP COLUMN column1, column2;

Steps

  1. I used the latest docker image to test it, on a Windows machine
  2. Execute docker run --rm -v ${PWD}:/sql sqlfluff/sqlfluff:3.3.0 lint /sql/drop_columns.sql --dialect=tsql
  3. This is the error I get
L:   2 | P:  20 |  PRS | Line 2, Position 20: Found unparsable section: ',
                       | column2;'
WARNING: Parsing errors found and dialect is set to 'tsql'. Have you configured your dialect correctly?

Dialect

tsql

Version

Docker image sqlfluff/sqlfluff:3.3.0

Configuration

None

Are you willing to work on and submit a PR to address the issue?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingt-sqlIssues related to the T-SQL/TSQL/Transact SQL dialect

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions