grammars-v4
grammars-v4 copied to clipboard
T-SQL grammar does not parse SWITCH PARTITION n TO correctly
Consider the T-SQL statement:
ALTER TABLE [dbo].[MyTable] SWITCH PARTITION 1 TO [dbo].[MyTable_Tombstone]
The current T-SQL Parser appears to break this statement into a parse tree with three top-level nodes:
ALTER: ALTER
TABLE: TABLE
table_name: [dbo].[MyTable] SWITCH PARTITION 1 TO [dbo].[MyTable_Tombstone]
However it should be something more like:
ALTER: ALTER
TABLE: TABLE
table_name: [dbo].[MyTable]
switch_partition: SWITCH PARTITION
DECIMAL: 1
TO: TO
table_name: [dbo].[MyTable_Tombstone]
I don't think it's relevant in this case but I'm using Antlr4 4.6.6 from NuGet in .NET 6.
Here is the relevant section on the Microsoft documentation.