private static List <string> GetTableReferences(string file, SqlEngineType engineType) { using (TextReader reader = File.OpenText(file)) { TSql140Parser parser = new TSql140Parser(initialQuotedIdentifiers: false, engineType: engineType); IList <ParseError> errors = null; StatementList statements = parser.ParseStatementList(reader, out errors); if (errors.Count > 0) { throw new Exception(string.Format("File {0} had {1} errors", file, errors.Count)); } TableVisitor visitor = new TableVisitor(); statements.Accept(visitor); List <string> tables = visitor.Tables.Distinct().OrderBy(t => t).ToList(); return(tables); } }