title: Call stored procedure from php codeigniter
body: <p>Looking for one week and did not found some content that I can use to execute a stored procedure.
  Scenario:</p>
  
  <p>I have copied the code that runs on SQL Server 2014 management in the Profiler window.</p>
  
  <p>I opened the SQL Studio and HeidiSQL and run the queries and it runs ok and returns me the expected result.</p>
  
  <p>When I tried to paste and modify this content to get the same result as I have on the SQL clients it did not run like it does in the SQL clients.
  How can I achieve this?</p>
  
  <p>eg: In my SQL I have 128 vars that I have to declare to run the stored procedure but to be more simple I will post only one var having in mind that sintaxe is the same to one or 128 vars right?</p>
  
  <pre><code>declare @var01 varchar(1000) set @var01='.$var01.'
  
  EXEC
  stored_procedure_y
  @var01 output
  
  SELECT
  @var01 AS any_value
  </code></pre>
  
  <p>I have tried many ways to execute the SQL commands with no success.
  Some examples that I tried to run:</p>
  
  <ul>
  <li><p>last</p>
  
  <pre><code>$declare_vars = 'declare @var01 varchar(1000) set @var01='.$var01.';
  $exec_sp = 'EXEC operacao_sitef @var01 output;
  $select_retorno = 'SELECT @var01 AS any_value;
  
  $queryDeclare = $this-&gt;db-&gt;query($declare_vars);
  
  $queryExec = $this-&gt;db-&gt;query($exec_sp);
      $queryRetorno = $this-&gt;db-&gt;query($select_retorno);
  
      return $queryRetorno;
  </code></pre>
  
  <p>Do not work.</p></li>
  <li><p>other</p>
  
  <pre><code>$query = $this-&gt;db-&gt;query('
  declare @var01 varchar(1000) set @var01='.$var01.'
  EXEC
  operacao_sitef
  @var01 output
  SELECT
  @var01 AS any_value
   ');
   return $query;
  </code></pre></li>
  </ul>
  
  <p>Also did not work.
  Any help would be appreciated. I'm newbie with SP's and don't know how to call this using codeigniter and collect the results to finalize the operation.</p>