Quick Start¶
Get up and running with General SQL Parser .NET in just a few minutes. This guide walks you through installation, your first parse, and the most common use cases.
Prerequisites¶
- .NET 10 SDK (the recommended target — LTS, supported through 2028-11). Older runtimes work via the
netstandard2.0facade: .NET Framework 4.6.1+, Mono, Unity, etc. - A C# IDE (Rider, Visual Studio, or VS Code with the C# Dev Kit).
- On Ubuntu 24.04:
sudo apt-get install -y dotnet-sdk-10.0(built into the Ubuntu apt feed; no Microsoft repo required). Verify withdotnet --info.
Installation¶
The library is published to NuGet as gudusoft.gsqlparser.
1 | |
1 2 3 | |
1 | |
The published NuGet ships with all 15 dialects baked in (DB2, Greenplum, Hive, Impala, Informix, MDX, MSSQL, MySQL, Netezza, Oracle, PostgreSQL, Redshift, Snowflake, Sybase, Teradata). If you build the library from source you can omit dialects with /p:includeXxx=true flags.
Trial vs full edition
The published NuGet is the full edition. The free trial (with a banner watermark in the output) is available as a separate ZIP from https://www.sqlparser.com/download.php; install with dotnet add package gudusoft.gsqlparser.trial once Gudu Software publishes the trial NuGet, or add the DLL via <Reference> for now.
Your first SQL parse¶
Create a new console project and add the package:
1 2 3 | |
Replace Program.cs with:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | |
Then dotnet run:
1 2 3 | |
Database vendor selection¶
Pick the matching EDbVendor constant when you construct the parser:
1 2 | |
1 2 | |
1 2 | |
1 2 | |
1 2 | |
The full list of supported EDbVendor constants: dbvdb2, dbvgreenplum, dbvhive, dbvimpala, dbvinformix, dbvmdx, dbvmssql (alias dbvaccess), dbvmysql, dbvnetezza, dbvoracle, dbvpostgresql, dbvredshift, dbvsnowflake, dbvsybase, dbvteradata.
Common use cases¶
1. Validate SQL¶
1 2 3 4 5 | |
2. Extract table names¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | |
3. Format SQL¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | |
The formatter is the same engine used by the formatsql demo (under gsp_demo_dotnet/src/demos/) — see that project for a full CLI implementation.
For step-by-step recipes — uppercase vs lowercase keywords, comma-first style, indent width, file round-tripping, multi-statement scripts, and a full reference of the GFmtOpt settings — see the dedicated Format (Pretty-print) SQL how-to.
Error handling¶
parse() returns 0 on success and non-zero on failure. Detailed errors live on Errormessage (a single string) and SyntaxErrors (a list with line/column information).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | |
Next steps¶
Now that you have GSP running, explore further:
Continue learning
- Getting Started with GSP — full guided tour
- Basic SQL Parsing — SELECT/INSERT/UPDATE/DELETE
- Working with Different Databases — vendor specifics
Troubleshooting¶
Parse error: unexpected token
Solution: Check that you're using the right EDbVendor. SQL syntax varies between vendors.
1 2 3 4 5 6 7 | |
TypeLoadException / FileNotFoundException at runtime
Solution: Make sure your project's TFM is one of net10.0, net8.0+, net6.0+, netstandard2.0-consuming, or net461+. If you're targeting net5.0 or older netcoreapp*, upgrade — those runtimes are EOL.
OutOfMemoryException on large scripts
Solution: Parse statement-by-statement instead of loading a multi-megabyte file as one string. See the performance optimization guide.
Getting help¶
- FAQ for common questions
- Support page for community help
- Email info@sqlparser.com for commercial support
Ready for more? Continue with the comprehensive tutorials or jump into a how-to guide.