title: using the TSqlParser
body: <p>I'm attempting to parse SQL using the TSql100Parser provided by microsoft. Right now I'm having a little trouble using it the way it seems to be intended to be used. Also, the lack of documentation doesn't help. (example: <a href="http://msdn.microsoft.com/en-us/library/microsoft.data.schema.scriptdom.sql.tsql100parser.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/microsoft.data.schema.scriptdom.sql.tsql100parser.aspx</a> )</p>
  
  <p>When I run a simple SELECT statement through the parser it returns a collection of TSqlStatements which contains a SELECT statement.
  Trouble is, the TSqlSelect statement doesn't contain attributes such as a WHERE clause, even though the clause is implemented as a class. <a href="http://msdn.microsoft.com/en-us/library/microsoft.data.schema.scriptdom.sql.whereclause.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/microsoft.data.schema.scriptdom.sql.whereclause.aspx</a>
  The parser does recognise the WHERE clause as such, looking at the token stream.
  So, my question is, am I using the parser correctly? Right now the token stream seems to be the most useful feature of the parser...</p>
  
  <p>My Test project:    </p>
  
  <pre><code>public static void Main(string[] args)
  {
      var parser = new TSql100Parser(false);
  
              IList&lt;ParseError&gt; Errors;
              IScriptFragment result = parser.Parse(
                  new StringReader("Select col from T1 where 1 = 1 group by 1;" +
                      "select col2 from T2;" +
                      "select col1 from tbl1 where id in (select id from tbl);"),
                      out Errors);
  
              var Script = result as TSqlScript;
  
              foreach (var ts in Script.Batches)
              {
                  Console.WriteLine("new batch");
  
                  foreach (var st in ts.Statements)
                  {
                      IterateStatement(st);
                  }
              }
  }
  
  static void IterateStatement(TSqlStatement statement)
  {
              Console.WriteLine("New Statement");
  
              if (statement is SelectStatement)
              {
                  PrintStatement(sstmnt);
              }
  }
  </code></pre>