.NET SQL Parser SDK for C# and VB.NET

Parse SQL, inspect its AST, validate and format queries, and trace data lineage in C# or VB.NET. GSP runs inside your .NET application, without a database connection.

Runnable C# demos on GitHub — lineage, formatting, table and column extraction, SQL rewriting, syntax checking, stored procedure analysis.

Examples verified with NuGet 4.1.0.18 · targets net10.0 and netstandard2.0

Short Answer

Use GSP .NET when your C# or VB.NET application needs more than syntax parsing: stable AST APIs with C# property access, dialect-aware analysis, table and column extraction, offline SQL validation, a production SQL formatter, and column-level lineage that runs locally inside an enterprise environment.

Key takeaways

15 dedicated grammarsOracle, SQL Server, PostgreSQL, MySQL, DB2, Teradata, Snowflake, Redshift, Hive, Impala, and more — each a compile-time switch.
Parser + lineage APIsC# parser properties and the formal DataFlowAnalyzer lineage API — all inside your .NET process.
net10.0 + netstandard2.0One package serves .NET 10 and .NET Framework 4.6.2+ consumers. Builds and runs on Linux, macOS, and Windows.

Evaluate GSP .NET 4.1.0.18 locally

Every snippet below was compiled against GSP .NET 4.1.0.18 and executed — the outputs in the comments are the program's real output, not illustrations. If you cannot use a public package repository, request the trial package and restore it from a local folder.

1. Reference the package

<!-- your .csproj -->
<ItemGroup>
  <PackageReference Include="gudusoft.gsqlparser" Version="4.1.0.18" />
</ItemGroup>

Pin the tested package with dotnet add package gudusoft.gsqlparser --version 4.1.0.18. This is the trial build: it parses statements up to 10,000 characters and parse() returns -1 above that. Use short queries or procedures for the initial evaluation. See below for an evaluation build without the limit. Air-gapped builds can restore the same package from an internal feed or a local folder.

2. Parse one SQL statement

using gudusoft.gsqlparser;

string sql = @"select c.customer_id, sum(o.amount) total
               from customers c join orders o on c.id = o.customer_id
               group by c.customer_id";

TGSqlParser parser = new TGSqlParser(EDbVendor.dbvoracle);
parser.sqltext = sql;
int result = parser.parse();

3. Handle parser errors clearly

if (result != 0)
{
    Console.WriteLine(parser.Errormessage);
    // e.g. syntax error, state:90(10101) near: from(1,8)
    return;
}

Errors carry the offending token with line and column position, so you can point a user straight at the problem.

4. Inspect AST, tables, and columns

using gudusoft.gsqlparser.nodes;

for (int i = 0; i < parser.sqlstatements.size(); i++)
{
    TCustomSqlStatement stmt = parser.sqlstatements.get(i);
    Console.WriteLine(stmt.sqlstatementtype);            // sstselect

    for (int t = 0; t < stmt.tables.size(); t++)
    {
        TTable table = stmt.tables.getTable(t);
        Console.WriteLine(table.FullName + " " + table.AliasName);
        // customers c
        // orders o
    }

    for (int c = 0; c < stmt.ResultColumnList.size(); c++)
    {
        TResultColumn rc = stmt.ResultColumnList.getResultColumn(c);
        Console.WriteLine(rc.Expr + (rc.AliasClause != null ? " AS " + rc.AliasClause : ""));
        // c.customer_id
        // sum(o.amount) AS total
    }
}

What your .NET product can build on

ASTStatement type, clauses, expressions, joins, predicates, functions, and nested query structure.
Tables and columnsSource tables, result columns, aliases, scopes, and references for downstream tooling.
ValidationParser and semantic error signals for invalid SQL, unsupported syntax, or catalog-aware checks.
Data lineageTrace source-to-target table and column dependencies for impact analysis and governance. Column lineage in C# →

Format SQL from the same parse tree

The formatter is part of the library, not a separate product — it renders the AST you already parsed, so it never reflows SQL it did not understand.

C#

using gudusoft.gsqlparser.pp.para;
using gudusoft.gsqlparser.pp.stmtformatter;

TGSqlParser parser = new TGSqlParser(EDbVendor.dbvmssql);
parser.sqltext = "select a.id,b.name from t1 a inner join t2 b on a.id=b.id "
               + "where a.status='X' order by 1";
if (parser.parse() != 0) { Console.Error.WriteLine(parser.Errormessage); return; }

GFmtOpt option = GFmtOptFactory.newInstance();
Console.WriteLine(FormatterFactory.pp(parser, option));

Output

SELECT   a.id,
         b.NAME
FROM     t1 a
         INNER JOIN t2 b
         ON a.id = b.id
WHERE    a.status = 'X'
ORDER BY 1

Build data lineage into your .NET application

A table list tells you which objects appear in a query. Column-level data lineage tells you which source columns produce each result. GSP .NET follows aliases, joins and expressions into target columns, so your C# application can answer where a value came from and what a change may affect.

SQL Server T-SQLTrace SELECT INTO, joins and aggregates, including STRING_AGG, CONCAT and calculated revenue columns in the worked example.
Oracle SQL and PL/SQLStart with view and aggregate lineage. Evaluate advanced packages, procedures, cursors and dynamic SQL with a current build and representative SQL.
XML, JSON and CSVCall DataFlowAnalyzer.generateDataFlow() or use the dlineage C# demo for files, directories, output formats and offline metadata.

The dedicated guide includes a runnable project, the actual output files, API usage and version boundaries.

One package, old and new .NET

net10.0.NET 10 (LTS) — the recommended target for new C# and VB.NET projects.
netstandard2.0.NET Framework 4.6.2+, and any other .NET Standard 2.0 consumer. Nothing to recompile for legacy WinForms/WPF/ASP.NET hosts.

Looking for the JVM instead? See the Java SQL Parser SDK. The two editions share parser concepts; the formal .NET lineage API follows the Java-compatible API while running entirely on .NET.

Questions .NET evaluators actually ask

Which API style does the .NET edition use?

The parser examples use C# properties such as parser.Errormessage, stmt.ResultColumnList and table.FullName. The formal data lineage API uses Java-compatible DataFlowAnalyzer constructors, Option, generateDataFlow() and model methods. Both run as C# in your .NET process; no JVM is required. Use the examples for the API and package version you are integrating.

Which SQL dialects does the .NET edition support?

15 dedicated grammars: Oracle, SQL Server (T-SQL), MySQL, PostgreSQL, IBM Db2, Sybase, IBM Informix, Snowflake, Amazon Redshift, Teradata, Greenplum, IBM Netezza, Apache Hive, Apache Impala, MDX. ANSI, generic, ODBC, Access, and Firebird are handled by the shared core grammar. BigQuery, SAP HANA, and DAX are available in the Java edition only — constructing a .NET parser for those vendors throws NotSupportedException rather than silently mis-parsing.

Can I ship a build with only the databases I license?

Yes. Each dialect is a compile-time switch (/p:includeOracle=true, /p:includeMssql=true, and so on), so a per-customer build carries only the grammar tables you paid for and nothing else. This keeps the shipped assembly small and the licensed surface explicit.

Does validating SQL require a database connection?

No. Parsing, validation, formatting, and lineage all run entirely in-process with no server, driver, or credentials. This is what makes GSP usable inside air-gapped and regulated environments.

Is the .NET edition on nuget.org?

Yes. The examples on this page use the public gudusoft.gsqlparser 4.1.0.18 trial package. Pin that version to reproduce them. The public trial has a 10,000-character SQL limit; request an evaluation build for larger scripts and the latest advanced lineage support. A newer evaluation or licensed DLL may contain changes not yet available on NuGet. Offline environments can restore packages from an internal feed or a local folder.

Can I analyze SQL data lineage from C#?

Yes, for every dialect the .NET SDK supports. The formal DataFlowAnalyzer API traces table and column lineage without a database connection. Use the dlineage C# demo for XML, JSON, CSV and graph data. The dedicated .NET SQL lineage guide includes tested SQL Server SELECT INTO and Oracle CREATE VIEW examples, plus guidance on metadata and advanced procedure evaluation.

Past 10,000 characters?

The nuget package is free and needs no request — but it stops at 10,000 characters per statement. Real stored procedures, migration scripts and generated queries run well past that, so ask for an evaluation build without the limit; Gudu can recommend the right API path at the same time. The playground takes statements up to 65,000 characters, so you can watch GSP handle one of yours first.