Problem calling SQL Server stored procedures

This does work:


$sql = "EXEC dbo.sp_radicar_expedientes";


This does not work:

$sql = "EXEC dbo.sp_radicar_expedientes";

$c = Yii::$app->db->createCommand($sql);


is it a bug?

// sql query for calling the procedure

$sql = "CALL procedure_name(:param_1, :param_2)";

// passing the params into to the sql query

$params = [':param_1'=>$param_1, ':param_2'=>$param_2,];

// execute the sql command

return Yii::$app->db->createCommand($sql, $params)->queryAll();

Reference : Executing SQL Queries and Executing Non-SELECT Queries

thank you. its helpful

Damn, this one was making me angry : (

I could execute SqlServer SP with parameters with this structure:

$sql2 = "EXEC sduma.dbo.testSP :vicParam";

$val = "ALV";

$params2 =[

   ':vicParam'=> $val


     $res =  Yii::$app->db->createCommand($sql, $params)->execute( );

        catch(Exception $ex){
            Yii::info($ex, $category = 'DBBB');

dont use parathesis when calling the SP, if need more than one param, just add it with a comma.