TSqlParser 0.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package TSqlParser --version 0.1.0
NuGet\Install-Package TSqlParser -Version 0.1.0
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="TSqlParser" Version="0.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add TSqlParser --version 0.1.0
#r "nuget: TSqlParser, 0.1.0"
#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.
// Install TSqlParser as a Cake Addin
#addin nuget:?package=TSqlParser&version=0.1.0

// Install TSqlParser as a Cake Tool
#tool nuget:?package=TSqlParser&version=0.1.0

TSqlParser

Why another parser ?

The goal of this project is to be able analyze T-Sql statements (similar to sp_depends someprocedurename) to get a list of tables touched with the operation type (UPDATE, INSERT, SELECT or DELETE) without having a connection to the database. If you have connection to the database, then definitely first review if sp_depends satisfies your requirements.

How is this different ?

sp_depends does not distinguish between updates and inserts and does not report on data being deleted from tables.

Cool, how can I use it ?

Reference TSqlParser.Core.dll and init SqlScriptAnalyzer. The ParserResults object has the collection of tables and stored procedures invoked.

string _sqlText = "INSERT INTO table1
SELECT a, b, c
FROM table2

EXEC pr_some_inner_procedure ";

SqlScriptAnalyzer _analyzer = new SqlScriptAnalyzer();
ParserResults actual = await _analyzer.AnalyzeSqlTextAsync(_sqlText);
Console.WriteLine(actual.ToString());

Parsing Result

  • Tables touched
    • table1 - INSERT
    • table2 - SELECT
    • Procedures Invoked
      • pr_some_inner_procedure

code on github @ https://github.com/console-writeline/t-sql-parser nuget package @ https://www.nuget.org/packages/TSqlParser

Product Compatible and additional computed target framework versions.
.NET Framework net47 is compatible.  net471 was computed.  net472 was computed.  net48 was computed.  net481 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
0.1.2 1,418 4/10/2018
0.1.0 890 4/5/2018