title: MSSQL slow with PHP Query
body: <p>I have a PHP page that's slow whenever it goes to query a MSSQL database. I'm using the latest PHP and the standard SQL odbc drivers to the connect to the database. When accessing the page My sql profiler goes crazy.The query is displayed then </p>
  
  <pre><code>exec sp_cursorfetch 180150003,2,1,1
  go
  </code></pre>
  
  <p>performs about 240 times before finally </p>
  
  <pre><code>exec sp_cursorclose 180150003
  go 
  </code></pre>
  
  <p>occurs and the page is displayed. </p>
  
  <p><img src="https://i.stack.imgur.com/S2Dyl.jpg" alt="Trace log Screenshot"></p>
  
  <p>This is the query causing the headache:</p>
  
  <pre><code>    &lt;?php
      $con = odbc_connect('Hesk','Trace_user','*******');
      $Assets = odbc_exec($con, "SELECT  AssetName,           AssetID From viewAssets ORDER BY [AssetName];");
  ?&gt;
  &lt;table Border ="0"   width="100%"&gt;
  &lt;tr&gt;
  &lt;td style="text-align:right" width="150"&gt;&lt;?php echo $hesklang   ['asset']; ?&gt;: &lt;font class="important"&gt;&lt;/font&gt;
  &lt;/td&gt;
  &lt;td width = "80%"&gt;&lt;select name ="asset"&gt;
  &lt;option value=""&gt;&lt;/option&gt;
  &lt;?php
      while ($row = odbc_fetch_array($Assets))
      {
      echo '&lt;option value="' . $row['AssetID'] . '"' .            (($_SESSION['c_asset'] == $row['AssetID']) ? '              selected="selected"' : '')
      . '&gt;' . $row['AssetName']. '&lt;/option&gt;';
      }
      odbc_close($con);
  ?&gt;
  &lt;/select&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>Any idea how my code is causing this performance holdup?</p>