SqlParser

Class SqlParser

Helper class for parsing sql statements

Inheritance
SqlParser
Namespace: ETLBox.Helper
Assembly: ETLBox.dll
Syntax
    public static class SqlParser

Methods

ParseColumnNames(string, string, string)

This method attempts to parse column names from any sql statement. E.g. SELECT 1 AS 'Test', Col2, t2.Col3 FROM table1 t1 INNER JOIN t2 ON t1.Id = t2.Id will return Test, Col2 and Col3 als column names.

Declaration
    public static List<string> ParseColumnNames(string sql, string QB = &quot;&quot;, string QE = &quot;&quot;)
Parameters
TypeNameDescription
stringsql

The sql code from which the column names should be parsed

stringQB

Optional: the start character used when quoting names (e.g. [ in SqlServer)

stringQE

Optional: the end character used when quoting names (e.g. ] in SqlServer)

Returns
TypeDescription
List<string>

The names of the columns in the sql

ReplaceMatchWith(Match)

Declaration
    public static string ReplaceMatchWith(Match match)
Parameters
TypeNameDescription
Matchmatch
Returns
TypeDescription
string