Question

This is strange, when I have the "begin tran" in the sp, it won't return any row, but if taken away, it works fine. Why is it so ? I am using codeigniter sqlsrv db driver.

sp

ALTER proc [dbo].[sp_test] @MembershipId int, @CardNumber varchar(50) as

begin tran
select 'hello world' hi
commit tran

php

$sql = sprintf("EXEC [sp_test] @MembershipId=0,@CardNumber=123");       
$query =  $this->oDb->query($sql);
print_r($query->result());
Was it helpful?

Solution

To those who may face this issue, the solution is so simple.

DON'T USE EXEC in the query, so should be this

$sql = sprintf("[sp_test] @MembershipId=0,@CardNumber=123");      
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top