BNF notation of T-SQL
Asked Answered
L

4

9

Do you know where can I get the BNF (Backus Naur Form) notation for the latest version of T-SQL from. This is the microsoft version and I can't find anything for it. I found SQL2 The revised ISO standard here also called SQL92 but it seems to lack some features of microsoft's T-SQL

Literator answered 31/1, 2012 at 18:21 Comment(3)
I don't believe that there is a published BNF for T-SQL.Fume
Perhaps if you revised your question to why you wanted such a thing/what problem you were seeking to solve, it could be achieved without?Fume
I'm developing something like intellisense for T-SQL (like RedGate's SQL Prompt). That's why I need the BNF notation in order to know what is the next available cosntruct/keyword.Literator
F
5

Have you checked out this btw?

General Sql Parser

They have enginered the notation from the ground up....

Fidler answered 6/6, 2012 at 10:59 Comment(1)
That is closed source which means: no BNF.Colver
M
5

I developed TSql grammar for ANTLR 4 in EBNF form. Check it in official grammars repository. It based on msdn description.

Currently implemented syntax:

  • Control of Flow (MSDN).
  • Cursors (MSDN).
  • Data manipulation language (DML):

  • Expressions (MSDN).
  • Predicates.
  • Transactions (MSDN).

And another syntax. Check grammar and test files for more detail.

Metathesis answered 10/2, 2016 at 9:48 Comment(2)
repository links are brokenBrownedoff
Thanks for the notice, I've fixed links.Metathesis
G
3

I know this is an old question, but I just found this grammar file hosted on bitbucket that can be used with GOLD Parsing System.

Since you're looking for TSQL's BNF (I was too), and it doesn't really exist, this grammar is the next best thing IMO.

Gallivant answered 5/6, 2014 at 20:5 Comment(0)
F
1

SQL-92 in BNF

SQL Server 2005 is based on SQL-92 with some SQL-99 features and Microsoft's T-SQL extensions. Best I have found currently.

Let me know if you find a more up to date one.....

Fidler answered 4/6, 2012 at 9:57 Comment(1)
Microsoft uses brackets to quote identifiers. This is far away from SQL-92.Colver

© 2022 - 2024 — McMap. All rights reserved.