title: Parsing and running .sql script using TinyTds Ruby Gem
body: <p>I am automating the deployment of db scripts for a push button nightly deploy. My first approach was to use sqlcmd on windows terminal, save the results to txt file, and parse it to ensure the script was successful. Parsing the file and finding the return code was problematic, so I turned to TinyTds. Here is my code:        </p>
  
  <pre><code>      client = TinyTds::Client.new(:username =&gt; DB_USER, :password =&gt; DB_PASSWORD, :dataserver =&gt; DB_SERVERNAME, :timeout =&gt; 1200)
        result = client.execute(IO.read(filename))
        puts result.return_code
  </code></pre>
  
  <p>Yields either nil or the following error (depending on the contents of the .sql script)</p>
  
  <pre><code>    run_sql.rb:24:in `execute': Attempt to initiate a new Adaptive Server operation with results pending (TinyTds::Error)
  </code></pre>
  
  <p>Changing</p>
  
  <pre><code>    result = client.execute(IO.read(filename))
  </code></pre>
  
  <p>to</p>
  
  <pre><code>    result = client.execute(IO.read(filename)).do
  </code></pre>
  
  <p>yields</p>
  
  <pre><code>    run_sql.rb:26:in `do': Incorrect syntax near 'go'. (TinyTds::Error)
  </code></pre>