Table of Contents

  1. Prerequisites
  2. Create a project
  3. Add the gudusoft.gsqlparser NuGet package
  4. Use the gudusoft.gsqlparser API in the app

Install General SQL Parser package from and once installed, refer to the package in code with using gudusoft.gsqlparser. You can then use the package’s API.


  • The .NET Core SDK, which provides the command-line dotnet tool.

Create a project

General SQL Parser packages can be installed into a .NET project of some kind. For this walkthrough, create a simple .NET Core console project as follows:

  1. Create a folder for the project.
  2. Create the project using the following command:

    dotnet new console

  3. Use dotnet run to test that the app has been created properly.

    dotnet run

Add the gudusoft.gsqlparser NuGet package

  1. Use the following command to install the gudusoft.gsqlparser package:

    dotnet add package gudusoft.gsqlparser

  2. After the command completes, open the .csproj file to see the added reference:

    <ItemGroup> <PackageReference Include="gudusoft.gsqlparser" Version="" /> </ItemGroup>

Use the gudusoft.gsqlparser API in the app

  1. Open the Program.cs file and add the following line at the top of the file:

    using gudusoft.gsqlparser;

  2. Replace the Main function with the following:

     static void Main(string[] args) {
         string sqlText = @"SELECT e.last_name AS name,
         e.commission_pct comm,
         e.salary * 12 ""Annual Salary""
         FROM scott.employees AS e
         WHERE e.salary > 1000 or 1=1
         ORDER BY
         TGSqlParser sqlparser = new TGSqlParser(EDbVendor.dbvoracle);
         Console.WriteLine("versionId: "+ TBaseType.versionId);
         Console.WriteLine("releaseDate: "+TBaseType.releaseDate);
         sqlparser.sqltext = sqlText;
         int ret = sqlparser.parse();
         if (ret == 0)
             Console.WriteLine("Congratulations, you have successfully setup the general SQL parser.");
             Console.WriteLine("Syntax error detected: {0}",sqlparser.Errormessage);
  3. Build and run the app by using the command

    dotnet run

    The output should be something like this:

    Congratulations, you have successfully setup the general SQL parser.