title: Cannot bring output rows of sql server into php using sqlsrv
body: <p>Please note that i tried all existing solutions and still haven't got output. </p>
  
  <p>I have a php page that calls a Stored Procedure in SQL Server using sqlsrv functions. I have tried existing solutions but unable to solve my problem. When i execute this same SP in SQL Management Studio, it gives output of 31 rows. However, here in my code i am unable to get any row of data. Could someone advise on how to?
  Here is my code:</p>
  
  <pre><code>$serverName = "(local)"; //serverName\instanceName
  // Server in the this format: &lt;computer&gt;\&lt;instance name&gt; or 
  // &lt;server&gt;,&lt;port&gt; when using a non default port number
  $connectionInfo = array( "Database"=&gt;"TESTDB");
  $conn = sqlsrv_connect( $serverName, $connectionInfo);
  
  if( $conn ) {
     $AcCode = '18100017';
     $StartDate = '2016/12/01';
     $EndDate = '2016/12/31';
     $CutAmt = -50000;
     $IntRate1 = 2;
     $IntRate2 = 3;
  
     $sql = "EXEC dbo.uspGetBankInterest @AC_NO= ?, @AsOfDate= ?, @EndDate= ? ,@CutAmt= ?, @IntRate1= ?, @IntRate2= ?";
      $stmt = sqlsrv_prepare($conn, $sql, array(&amp;$AcCode,&amp;$StartDate,&amp;$EndDate,&amp;$CutAmt,&amp;$IntRate1,&amp;$IntRate2));
      $result=sqlsrv_execute($stmt);
      if( !$stmt ) {
          die( print_r( sqlsrv_errors(), true));
      }
  
      if($result){
          echo "SP Executed!";
      }
  
     $ctr=0;
      $row_count = sqlsrv_num_rows( $stmt );
      echo ' '.$row_count.'&lt;br&gt;';
      while($row = sqlsrv_fetch_array($stmt,SQLSRV_FETCH_ASSOC))
          {
              print_r($stmt);
              echo($row['STAT_DATE'].' '.$row['STAT_AMT'].' '.$row['INT_AMT']."&lt;br&gt;");
              $ctr++; 
          }
          echo 'The total number of records are:'.$ctr;
  
      die();
  }
  
  else{
   echo "Connection could not be established.&lt;br /&gt;";
   die( print_r( sqlsrv_errors(), true));
  }
  </code></pre>
  
  <p>The output i get is: </p>
  
  <blockquote>
    <p>SP Executed! 
    The total number of records are:0</p>
  </blockquote>
  
  <p>When i executed, there was an output of 31 records and the data was displayed correctly. There is no problem in my SP. However, when i am trying it in php, no data is brought. How can i solve this problem?</p>