Skip to content

MsSql: Accept statements without semicolons in BEGIN ... END blocks - #2994

Open
colinhacks wants to merge 2 commits into
apache:mainfrom
colinhacks:mssql-statement-list-optional-semicolon
Open

colinhacks wants to merge 2 commits into
apache:mainfrom
colinhacks:mssql-statement-list-optional-semicolon

Conversation

@colinhacks

Copy link
Copy Markdown

Dialects: MsSql, Generic

With require_semicolon_stmt_delimiter = false, statements at the top level of a batch need no ;, but statements inside a BEGIN ... END block, a WHILE body, or a procedure, function or trigger body still did. BEGIN SELECT 1 SELECT 2 END failed with Expected: ;, found: SELECT, and WHILE @i < 3 BEGIN SET @i = @i + 1; SELECT @i END with Expected: ;, found: END. T-SQL makes the semicolon optional in both places (https://learn.microsoft.com/en-us/sql/t-sql/language-elements/transact-sql-syntax-conventions-transact-sql).

parse_statement_list now skips any ; before and after each statement when the option is off, as parse_statements does at the top level. With the default options a ; is still required after each statement. The same change was part of #1949.

Not covered: with the option off, a keyword that ends a block can still be read as an implicit alias in dialects that accept it as one, as statement keywords can be at the top level today, e.g. ELSE in Generic's IF x THEN SELECT a FROM t ELSE .... For MsSql, statement keywords read as implicit aliases are #2991, and a WHILE without BEGIN taking the statements after it is #2992.

Refs #1800

Written with an AI coding assistant.

Copilot AI balanced review requested due to automatic review settings November 17, 2026 18:32

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants