You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SQL Server: Increase support for multi statement object definitions (without semicolons) #1800
It would be extremely useful if this library was able to properly parse multiple statements, particularly in a object definition body, without requiring semi-colons which are optional for SQL Server.
The following otherwise valid SQL fails parsing (MSSQL dialect):
create or alter procedure test()
as
begin
declare @x bit = 1
if @x = 1
begin
select 1
end
end
The error is at the if @x = 1 line:
end of statement, found: if
The problem appears to be related to parsing multiple statements in the object definition body. The parsing concludes successfully if the code is changed to declare @x bit = 1; with a semi-colon.
There's also the similar case of two top level statements:
declare @x bit = 1
if @x = 1
begin
select 1
end
The API I was using was parse_sql:
staticDIALECT: sqlparser::dialect::MsSqlDialect = sqlparser::dialect::MsSqlDialect{};let sql_text = ...
let mut statements = Parser::parse_sql(&DIALECT, sql_text.as_str())?;// error: end of statement, found: if
There's a workaround for the multiple top level statements scenario, but that won't work for the stored procedure example:
changed the title [-]SQL Server: Increase support for multi statement object definitions[/-][+]SQL Server: Increase support for multi statement object definitions (without semicolons)[/+]on May 7, 2025
Activity
[-]SQL Server: Increase support for multi statement object definitions[/-][+]SQL Server: Increase support for multi statement object definitions (without semicolons)[/+]aharpervc commentedon Mar 5, 2026
The related PR in this repo went stale, but the branch on my fork is still functional with all tests passing, if anyone else is interested: https://github.com/aharpervc/datafusion-sqlparser-rs/tree/expand-parse-without-semicolons