SqlBuildingBlocks.Grammars.SQLServer
1.0.0.305
dotnet add package SqlBuildingBlocks.Grammars.SQLServer --version 1.0.0.305
NuGet\Install-Package SqlBuildingBlocks.Grammars.SQLServer -Version 1.0.0.305
<PackageReference Include="SqlBuildingBlocks.Grammars.SQLServer" Version="1.0.0.305" />
<PackageVersion Include="SqlBuildingBlocks.Grammars.SQLServer" Version="1.0.0.305" />
<PackageReference Include="SqlBuildingBlocks.Grammars.SQLServer" />
paket add SqlBuildingBlocks.Grammars.SQLServer --version 1.0.0.305
#r "nuget: SqlBuildingBlocks.Grammars.SQLServer, 1.0.0.305"
#:package SqlBuildingBlocks.Grammars.SQLServer@1.0.0.305
#addin nuget:?package=SqlBuildingBlocks.Grammars.SQLServer&version=1.0.0.305
#tool nuget:?package=SqlBuildingBlocks.Grammars.SQLServer&version=1.0.0.305
SqlBuildingBlocks
Project Status
| Component | Status |
|---|---|
| AnsiSQL grammar | Production-ready — SQL-89 + FETCH FIRST, 86+ negative tests per dialect |
| MySQL grammar | Production-ready — backticks, LIMIT/OFFSET, INTERVAL, ON DUPLICATE KEY UPDATE |
| PostgreSQL grammar | In development (stub — do not use in production) |
| SQL Server grammar | In development (stub — do not use in production) |
| Query engine | Beta — SELECT with CTEs (recursive + non-recursive), JOINs, window functions, aggregates, UNION/INTERSECT/EXCEPT, ORDER BY, GROUP BY/HAVING |
Overview
SqlBuildingBlocks is an extensible open-source library for parsing SQL into manageable, logical classes tailored to different database technologies. It is built upon Irony's SQLGrammar example and leverages the Factory and Strategy patterns for customization of SQL parsing across multiple databases.
How It Works
SqlBuildingBlocks breaks down SQL into fundamental "building blocks" — NonTerminal classes, each handling a specific part of the SQL language. These NonTerminal classes use a factory pattern to create logical classes that represent SQL elements.
Query Engine
The QueryEngine class provides in-memory SQL execution. It accepts an ITableDataProvider (or IAllTableDataProvider for multi-table queries) and a parsed SqlSelectDefinition, and returns a VirtualDataTable of result rows.
Supported SELECT features:
- Simple projections, column aliases,
SELECT * FROMtable,INNER/LEFT/RIGHT/FULL OUTER JOINWHEREclause with full predicate support (comparisons,IS NULL,LIKE,IN,BETWEEN, logical operators)GROUP BY+HAVING(aggregate predicates)ORDER BYwithASC/DESCandNULLS FIRST/NULLS LASTDISTINCT- Aggregate functions:
COUNT,SUM,AVG,MIN,MAX(includingCOUNT(DISTINCT col)) - Window functions:
ROW_NUMBER,RANK,DENSE_RANK,LAG,LEAD,NTILE,FIRST_VALUE,LAST_VALUE,NTH_VALUE;ROWS BETWEENframes;RANGE BETWEEN INTERVALframes (DateTime ORDER BY) WITH(non-recursive CTE) andWITH RECURSIVECTE; configurable depth limit viaQueryEngineOptions.MaxRecursionDepth(default 100)UNION,UNION ALL,INTERSECT,EXCEPT- Derived tables in
FROMandJOINpositions - SQL Server
TOP N - DBNull / three-valued logic in all predicates
Not yet supported (throws NotSupportedException): correlated subqueries, EXISTS, ROLLUP/CUBE/GROUPING SETS, GROUP BY ROLLUP, DML execution (INSERT/UPDATE/DELETE are parse-only).
// Parse
var grammar = new AnsiSqlGrammar();
var parser = new Parser(grammar);
var parseTree = parser.Parse("SELECT * FROM Orders WHERE Amount > 100");
// Resolve
var resolver = new SelectReferenceResolver(selectDef, connectionProvider, schemaProvider, functionProvider);
resolver.ResolveTablesDatabase();
resolver.ResolveReferences();
// Execute
var engine = new QueryEngine(tableDataProvider, selectDef);
var result = engine.QueryAsDataTable();
Project Objectives
- Extensibility: Specialized grammars for each database technology, extending a shared AnsiSQL base.
- Usability: Represent complex SQL grammar as manageable, logical classes.
- Testability: Strong unit-testing framework — 1279 passing tests across five NuGet packages.
Roadmap
- PostgreSQL grammar — dialect extensions beyond the current stub
- SQL Server grammar — dialect extensions beyond the current stub
- Correlated subquery execution
GROUP BY ROLLUP/CUBE/GROUPING SETSexecution
Contributing
We're open to contributions from the community. Please refer to our contributing guidelines for more information.
License
This project is licensed under the terms of the MIT license. For more information, please see the LICENSE file.
Installation
Install via NuGet. All five packages publish at the same version on every merge to main.
| Package Name | Release (NuGet) |
|---|---|
SqlBuildingBlocks.Core |
|
SqlBuildingBlocks.Grammars.AnsiSQL |
|
SqlBuildingBlocks.Grammars.MySQL |
|
SqlBuildingBlocks.Grammars.PostgreSQL |
|
SqlBuildingBlocks.Grammars.SQLServer |
Contact
For any inquiries or issues, please open a GitHub issue.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- SqlBuildingBlocks.Core (>= 1.0.0.305)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on SqlBuildingBlocks.Grammars.SQLServer:
| Package | Downloads |
|---|---|
|
ServantSoftware.Data.Common
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0.305 | 95 | 5/17/2026 |
| 1.0.0.303 | 92 | 5/12/2026 |
| 1.0.0.302 | 99 | 5/10/2026 |
| 1.0.0.301 | 97 | 5/10/2026 |
| 1.0.0.300 | 93 | 5/10/2026 |
| 1.0.0.299 | 95 | 5/10/2026 |
| 1.0.0.298 | 101 | 5/10/2026 |
| 1.0.0.296 | 88 | 5/10/2026 |
| 1.0.0.295 | 97 | 5/10/2026 |
| 1.0.0.294 | 100 | 5/10/2026 |
| 1.0.0.293 | 93 | 5/10/2026 |
| 1.0.0.292 | 87 | 5/10/2026 |
| 1.0.0.291 | 102 | 5/10/2026 |
| 1.0.0.290 | 94 | 5/9/2026 |
| 1.0.0.289 | 92 | 5/9/2026 |
| 1.0.0.288 | 105 | 5/9/2026 |
| 1.0.0.287 | 100 | 5/9/2026 |
| 1.0.0.286 | 175 | 5/9/2026 |
| 1.0.0.285 | 98 | 5/9/2026 |
| 1.0.0.284 | 100 | 5/9/2026 |