gudusoft.gsqlparser 4.1.0.8

dotnet add package gudusoft.gsqlparser --version 4.1.0.8
                    
NuGet\Install-Package gudusoft.gsqlparser -Version 4.1.0.8
                    
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.8" />
                    
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.8" />
                    
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.8
                    
#r "nuget: gudusoft.gsqlparser, 4.1.0.8"
                    
#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.8
                    
#: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.8
                    
Install as a Cake Addin
#tool nuget:?package=gudusoft.gsqlparser&version=4.1.0.8
                    
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.8 62 7/30/2026
4.1.0.7 186 7/26/2026
4.1.0.6 103 7/25/2026
3.3.0.4 149,726 9/3/2019
3.3.0.2 20,675 4/17/2019
3.3.0.1 2,269 4/16/2019
3.2.6.5 3,568 9/5/2018
3.2.6.3 2,481 9/4/2018
3.2.6 6,355 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.8

- [Oracle] Accept the IGNORE NULLS and RESPECT NULLS null-treatment
 clauses after the closing parenthesis of a value-based window
 function, before OVER, e.g.
 LAG(var1, 1, var1) IGNORE NULLS OVER (ORDER BY ROWNUM),
 LEAD(var1) RESPECT NULLS OVER (...),
 FIRST_VALUE(var1) IGNORE NULLS OVER (...),
 LAST_VALUE(var1) RESPECT NULLS OVER (...) and
 NTH_VALUE(var1, 3) IGNORE NULLS OVER (...). Previously only the
 FIRST_VALUE/LAST_VALUE inside-parenthesis IGNORE NULLS form was
 accepted. RESPECT, LAG, LEAD and NTH_VALUE are unreserved keywords and
 stay usable as ordinary identifiers.
- [Oracle] Support JSON_TABLE in the FROM clause, including the
 COLUMNS list with value / EXISTS / FORMAT JSON query / NESTED PATH /
 FOR ORDINALITY columns, wrapper clauses, and ON ERROR / ON EMPTY
 handlers (ERROR/NULL/DEFAULT expr/EMPTY [ARRAY|OBJECT]), with or
 without a table alias. The new keywords (JSON_TABLE, PATH, FORMAT,
 JSON, WRAPPER, CONDITIONAL, UNCONDITIONAL, ORDINALITY) remain usable
 as ordinary identifiers.
- [DB2] Accept a decimal literal with no leading digit directly after
 an operator, e.g. decimal(...)+.005 or a>=.5. The lexer previously
 glued the operator and the dot into one token.
- [demos] The sample programs now live in their own public repository,
 github.com/sqlparser/gsp_demo_dotnet, and consume the published
 gudusoft.gsqlparser package from nuget.org. The release ZIP includes
 a demos.md pointer instead of vendored demo sources.

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