I would like to parse SQL INSERT statements into object (represented as a text). There is an SQL script file containing:
INSERT INTO Document(Id, Name, Description ...)
VALUES('DC001', 'FOO', 'bar');
INSERT INTO DocType(Id, Name)
VALUES('DT001', 'DOCX');
and many more table inserts.
What is the easiest way to parse out Table names (Document, DocType,..)?
Would it be possible with RegEx, if I don't wanna calculate substrings?
const string pattern = @"INSERT INTO\s\w";
foreach (var line in FileContent)
{
var a = Regex.Match(line, pattern, RegexOptions.Compiled | RegexOptions.IgnoreCase);
if (a.Success)
{
}
}