Looking for one week and did not found some content that I can use to execute a stored procedure. Scenario:
I have copied the code that runs on SQL Server 2014 management in the Profiler window.
I opened the SQL Studio and HeidiSQL and run the queries and it runs ok and returns me the expected result.
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?
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?
declare @var01 varchar(1000) set @var01='.$var01.'
EXEC
stored_procedure_y
@var01 output
SELECT
@var01 AS any_value
I have tried many ways to execute the SQL commands with no success. Some examples that I tried to run:
last
$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->db->query($declare_vars); $queryExec = $this->db->query($exec_sp); $queryRetorno = $this->db->query($select_retorno); return $queryRetorno;
Do not work.
other
$query = $this->db->query(' declare @var01 varchar(1000) set @var01='.$var01.' EXEC operacao_sitef @var01 output SELECT @var01 AS any_value '); return $query;
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.