Call a sqlserver stored procedure with an output variable

Hi,
is there a way to call a SqlServer stored procedure wich has an output parameter and store the result to a php variable?
I’ve tried this solution from @Giu but doesn’t work for me.

1 Like

In your stored procedure you need to save the result in an a transition SQL table

You need to pass an extra parameter to retrieve the data back, like the PHP_SESSION

Call the Stored Procedure normally (including the extra parameter)

Retrieve your data in the transition table using the extra parameter as an index

1 Like

It is quite straightforward

			$str_sp = "EXEC $sp @site_id=".[site_id].", @import_id=$import_id, @commands='".[commands]."',@session_id='$uniqid'";
			echo "<br>-- <b>Import $n from $total </b><br>
			-- Executing $sp for $procedure_name <br>$str_sp";
			
			sc_lookup(rs1,$str_sp);		
			if(isset({rs1[0][0]}))	{echo '<br>SP output: '.{rs1[0][0]};}