title: 'PDOException' with message 'SQLSTATE[07002]: [Microsoft][SQL Server Native Client 11.0]COUNT field incorrect or syntax error' in .../db.php:46
body: <p><code>Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[07002]: [Microsoft][SQL Server Native Client 11.0]COUNT field incorrect or syntax error' in .../db.php:46 Stack trace: #0 .../db.php(46): PDOStatement-&gt;execute() #1 .../tests/testDb.php(12): ReportsDB-&gt;runSP('CALL ...', Array) #2 {main} thrown in .../db.php on line 46</code></p>
  
  <p>I am getting this error on some code I am working on. I am having problems debugging this particular error message.</p>
  
  <p>Here's what's encapsulating line 46 (I'll highlight the actual line).</p>
  
  <pre><code>public function runSP ($sp, array $args) {
  
      $returnParams = array();
  
      if ($sp) {
  
          $s = explode(" ", $sp);
          if ($s[0] != "CALL") {
              $sp = "CALL " . $sp;
          }
  
          $stmt = $this-&gt;_db-&gt;prepare($sp);
  
          if (sizeof($args) &gt; 0) {
  
              for ($i = 0; $i &gt; sizeof($args); $i++) {
  
                  $stmt-&gt;bindParam($i, $args[$i]["value"], $args[$i]["type"]);
  
                  $t = explode("|", $args[$i]["type"]);
                  if ($t[1] == "PDO::PARAM_INPUT_OUTPUT") {
                      $returnParams[] = $args[$i]["value"];
                  }
              }
  
  Line 46     $stmt-&gt;execute();
  
              return $returnParams;
  
      } else {
  
      }
  
  }
  </code></pre>