ScriptDom parser for Sql Server 2022 fails to parse exec variable with version
Turyansky opened this issue · 2 comments
Turyansky commented
- SqlPackage or DacFx Version: 161.6367.0-preview
- .NET Framework (Windows-only) or .NET Core: .Net 6.0
- Environment (local platform and source/target platforms): N/A
Steps to Reproduce:
- Create a new C# Console Project
- Add latest Nuget package for Microsoft.SqlServer.DacFx (161.6367.0-preview)
- Run code below
using Microsoft.SqlServer.TransactSql.ScriptDom;
var parser = new TSql160Parser(true); // Sql server 2022 parser
IList<ParseError> errors;
parser.Parse(new StringReader("CREATE PROCEDURE Proc1 AS EXEC ProcName;2"), out errors);
// No parsing errors
parser.Parse(new StringReader("CREATE PROCEDURE Proc1 AS DECLARE @ProcName SYSNAME = 'Proc2' EXEC @ProcName"), out errors);
// No parsing errors
parser.Parse(new StringReader("CREATE PROCEDURE Proc1 AS DECLARE @ProcName SYSNAME = 'Proc2' EXEC @ProcName;2"), out errors);
// Parsing error! "Incorrect syntax near ;." This should parse succesfully
Did this occur in prior versions? If not - which version(s) did it work in?
Not work in all prior versions.
(DacFx/SqlPackage/SSMS/Azure Data Studio)
barbaravaldez commented
Hi @Turyansky, thank you for submitting this issue. I couldn't find documentation of variable versioning in SQL Server. Can you please clarify the issue? What does ";2" mean in this case?
poizan42 commented
AFAICT it is equivalent to
CREATE PROCEDURE Proc1 AS
BEGIN
DECLARE @ProcName SYSNAME = 'Proc2'
EXEC @ProcName;2
END
The ";2" is the "procedure group" functionality, see ";number" at https://learn.microsoft.com/en-us/sql/t-sql/language-elements/execute-transact-sql?view=sql-server-ver16