gudusoft.gsqlparser 4.1.0.13

dotnet add package gudusoft.gsqlparser --version 4.1.0.13
                    
NuGet\Install-Package gudusoft.gsqlparser -Version 4.1.0.13
                    
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="gudusoft.gsqlparser" Version="4.1.0.13" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="gudusoft.gsqlparser" Version="4.1.0.13" />
                    
Directory.Packages.props
<PackageReference Include="gudusoft.gsqlparser" />
                    
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 gudusoft.gsqlparser --version 4.1.0.13
                    
#r "nuget: gudusoft.gsqlparser, 4.1.0.13"
                    
#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 gudusoft.gsqlparser@4.1.0.13
                    
#: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=gudusoft.gsqlparser&version=4.1.0.13
                    
Install as a Cake Addin
#tool nuget:?package=gudusoft.gsqlparser&version=4.1.0.13
                    
Install as a Cake Tool

Trial edition. This package refuses SQL longer than 10,000 characters: parse() returns -1 and Errormessage reads "trial version can only process query with size less than 10000 characters". That is the trial limit, not a parse error in your SQL. Everything else behaves exactly as the full edition, which is available from https://www.sqlparser.com.

General SQL Parser .NET

Parse, analyze, modify and format SQL from 15 database vendors, in process, with no database connection.

Given a query, you get a parse tree you can walk: statement types, tables, columns, expressions, joins, CTEs, subqueries. You can rewrite the tree and generate SQL back out, or run the formatter over it.

Install

dotnet add package gudusoft.gsqlparser

Quick start

using gudusoft.gsqlparser;
using gudusoft.gsqlparser.nodes;
using gudusoft.gsqlparser.stmt;

var parser = new TGSqlParser(EDbVendor.dbvoracle);
parser.sqltext = "SELECT dept_id, COUNT(*) AS headcount "
               + "FROM employees e JOIN departments d ON e.dept_id = d.id "
               + "WHERE e.salary > 50000 GROUP BY dept_id";

if (parser.parse() != 0)
{
    Console.WriteLine(parser.Errormessage);
    return;
}

var select = (TSelectSqlStatement)parser.sqlstatements.get(0);
Console.WriteLine($"statement type: {select.sqlstatementtype}");

foreach (TTable table in select.tables)
    Console.WriteLine($"table:  {table.FullName}");

for (int i = 0; i < select.ResultColumnList.size(); i++)
    Console.WriteLine($"column: {select.ResultColumnList.getResultColumn(i).Expr}");

Output:

statement type: sstselect
table:  employees
table:  departments
column: dept_id
column: COUNT(*)

parse() returns 0 on success. On failure it returns non-zero and Errormessage explains why.

Supported databases

Pass the matching EDbVendor to the constructor:

Database EDbVendor Database EDbVendor
Oracle dbvoracle Snowflake dbvsnowflake
SQL Server dbvmssql Teradata dbvteradata
PostgreSQL dbvpostgresql Greenplum dbvgreenplum
MySQL dbvmysql Redshift dbvredshift
DB2 dbvdb2 Netezza dbvnetezza
Hive dbvhive Informix dbvinformix
Impala dbvimpala Sybase dbvsybase
MDX dbvmdx

Target frameworks

net10.0 and netstandard2.0. The netstandard2.0 build covers .NET Framework 4.6.2+, Mono and Unity. (4.6.2, not 4.6.1: the netstandard2.0 build depends on System.Text.Json 8.0.5, whose lowest .NET Framework asset is net462.)

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 is compatible.  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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.1.0.13 62 8/8/2026
4.1.0.12 44 8/8/2026
4.1.0.11 46 8/8/2026
4.1.0.10 43 8/8/2026
4.1.0.9 63 8/7/2026
4.1.0.8 191 7/30/2026
4.1.0.7 202 7/26/2026
4.1.0.6 113 7/25/2026
3.3.0.4 150,840 9/3/2019
3.3.0.2 20,737 4/17/2019
3.3.0.1 2,275 4/16/2019
3.2.6.5 3,575 9/5/2018
3.2.6.3 2,486 9/4/2018
3.2.6 6,384 9/4/2018

TRIAL EDITION - SQL longer than 10,000 characters is rejected (parse() returns -1). Full edition: https://www.sqlparser.com/

Release 4.1.0.13

- [DB2] Accept two more spellings of a condition declaration in a
 procedure, trigger or function body:
   * with the SQLSTATE keyword omitted, which is how IBM writes it,
     for example DECLARE DUPEKEY CONDITION FOR '23505'
   * with no SQLSTATE at all, for example DECLARE retryable CONDITION
     The SQLSTATE association is optional in a compound SQL
     (compiled) statement, which is what a routine body is; such a
     condition can still be referenced from a handler and from
     SIGNAL.
 The forms that already worked, CONDITION FOR SQLSTATE '23505' and
 CONDITION FOR SQLSTATE VALUE '23505', are unchanged.

Demos: https://github.com/sqlparser/gsp_demo_dotnet