gudusoft.gsqlparser 4.1.0.14

dotnet add package gudusoft.gsqlparser --version 4.1.0.14
                    
NuGet\Install-Package gudusoft.gsqlparser -Version 4.1.0.14
                    
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.14" />
                    
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.14" />
                    
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.14
                    
#r "nuget: gudusoft.gsqlparser, 4.1.0.14"
                    
#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.14
                    
#: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.14
                    
Install as a Cake Addin
#tool nuget:?package=gudusoft.gsqlparser&version=4.1.0.14
                    
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.14 530 8/27/2026
4.1.0.13 371 8/8/2026
4.1.0.12 109 8/8/2026
4.1.0.11 110 8/8/2026
4.1.0.10 112 8/8/2026
4.1.0.9 123 8/7/2026
4.1.0.8 214 7/30/2026
4.1.0.7 219 7/26/2026
4.1.0.6 125 7/25/2026
3.3.0.4 156,011 9/3/2019
3.3.0.2 21,028 4/17/2019
3.3.0.1 2,282 4/16/2019
3.2.6.5 3,580 9/5/2018
3.2.6.3 2,497 9/4/2018
3.2.6 6,421 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.14

- [DB2] Support four Db2 12.1 constructs that previously failed to
 parse:
   * the EXISTS predicate used as a select-list expression, for
     example SELECT EXISTS(SELECT c FROM t2) AS found FROM t1. Db2
     lists search-condition as an alternative in its `expression`
     diagram, so a predicate is legal wherever an expression is and
     the result column is BOOLEAN. NOT EXISTS is accepted too.
   * the SET TENANT statement, in every documented spelling:
     SET [CURRENT] TENANT [=] value, SET CURRENT_TENANT [=] value,
     and the ISO/ANSI alias SET [CURRENT] CATALOG [=] value. The
     value may be an identifier, a delimited identifier, a string
     constant, SYSTEM, or a parameter marker. TENANT, CURRENT_TENANT
     and CATALOG are not Db2 reserved words and remain usable as
     ordinary identifiers.
   * the fetch-clause and order-by-clause on a searched DELETE or
     UPDATE, for example
     DELETE FROM t WHERE c = 1 FETCH FIRST 100 ROWS ONLY. The row
     count is an expression, so an SQL variable or a parameter
     marker works as well as a literal. Exposed as
     TDeleteSqlStatement.FetchFirstClause and
     TUpdateSqlStatement.FetchFirstClause;
     TUpdateSqlStatement.OrderByClause is now populated as well.
   * the FROM clause of a searched UPDATE, which sits between the SET
     list and WHERE, for example
     UPDATE t1 h SET (h.a, h.b) = (r.a, r.b)
       FROM (SELECT a, b, k FROM t2) r WHERE h.k = r.k.
     Plain tables, comma-separated lists, derived tables and JOIN /
     LEFT JOIN forms are all accepted, with or without correlation
     names, and the source tables appear in stmt.tables and
     stmt.joins.
 Db2 has no DELETE ... FROM source-table form, so that is still
 rejected.

- [DB2] Distinguish the searched and positioned forms of UPDATE and
 DELETE. The FROM, ORDER BY and FETCH FIRST clauses belong to the
 searched form only, so a positioned statement such as
 DELETE FROM t WHERE CURRENT OF c FETCH FIRST 5 ROWS ONLY is now
 rejected rather than silently accepted.

- [DB2] Preserve the fetch-clause of a searched UPDATE or DELETE when
 regenerating SQL from a modified parse tree. The script writer
 emitted it for SELECT only, so a round trip previously turned
 "delete at most 100 rows" into "delete every matching row".

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