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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SqlBuildingBlocks.Grammars.SQLServer" Version="1.0.0.305" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SqlBuildingBlocks.Grammars.SQLServer" Version="1.0.0.305" />
                    
Directory.Packages.props
<PackageReference Include="SqlBuildingBlocks.Grammars.SQLServer" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SqlBuildingBlocks.Grammars.SQLServer --version 1.0.0.305
                    
#r "nuget: SqlBuildingBlocks.Grammars.SQLServer, 1.0.0.305"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SqlBuildingBlocks.Grammars.SQLServer@1.0.0.305
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SqlBuildingBlocks.Grammars.SQLServer&version=1.0.0.305
                    
Install as a Cake Addin
#tool nuget:?package=SqlBuildingBlocks.Grammars.SQLServer&version=1.0.0.305
                    
Install as a Cake Tool

SqlBuildingBlocks

Build

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 *
  • FROM table, INNER/LEFT/RIGHT/FULL OUTER JOIN
  • WHERE clause with full predicate support (comparisons, IS NULL, LIKE, IN, BETWEEN, logical operators)
  • GROUP BY + HAVING (aggregate predicates)
  • ORDER BY with ASC/DESC and NULLS FIRST/NULLS LAST
  • DISTINCT
  • Aggregate functions: COUNT, SUM, AVG, MIN, MAX (including COUNT(DISTINCT col))
  • Window functions: ROW_NUMBER, RANK, DENSE_RANK, LAG, LEAD, NTILE, FIRST_VALUE, LAST_VALUE, NTH_VALUE; ROWS BETWEEN frames; RANGE BETWEEN INTERVAL frames (DateTime ORDER BY)
  • WITH (non-recursive CTE) and WITH RECURSIVE CTE; configurable depth limit via QueryEngineOptions.MaxRecursionDepth (default 100)
  • UNION, UNION ALL, INTERSECT, EXCEPT
  • Derived tables in FROM and JOIN positions
  • 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 SETS execution

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 NuGet
SqlBuildingBlocks.Grammars.AnsiSQL NuGet
SqlBuildingBlocks.Grammars.MySQL NuGet
SqlBuildingBlocks.Grammars.PostgreSQL NuGet
SqlBuildingBlocks.Grammars.SQLServer NuGet

Contact

For any inquiries or issues, please open a GitHub issue.

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
Loading failed