This question relates to:
PHP Version 5.3.6
I am trying to properly retrieve data from a stored procedure.
This question assumes the existence of the following stored procedure:
CREATE PROCEDURE test_procedure
AS
BEGIN
SET NOCOUNT ON
--A bunch of SQL statements
--More SQL statements
SELECT 'Doctor Who Rules!'
END
I've tried the following code which runs through all of my commands but does not return the data from the final SELECT.
$sql = "EXEC test_procedure;";
$result = sqlsrv_query($conn,$sql);
$next_result = sqlsrv_next_result($result); // returns a boolean
$row = sqlsrv_fetch_array($result);
Using sqlsrv_execute does not work with the above code either.
How can I return the data geneated by the stored procedure above via PHP?
Thank you.
Addendum #1 (Classic ASP Counterpart)
sqlCMD = "EXEC test_procedure;"
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open _ConnectionString_Variable_
Set rs = conn.Execute(sqlCMD)
I would get back a recordset with one row that has one field with the data "Doctor Who Rules!"