I have a stored procedure written in T-SQL and want to use a table variable.
Here is a simple example:
CREATE PROCEDURE test
AS
BEGIN
DECLARE @tempTable TABLE(
id int, data nvarchar(128)
)
INSERT INTO @tempTable (id, data)
SELECT id, data FROM otherTable
SELECT * FROM @tempTable
END
I create the procedure on MS SQL Server 2008 running on Windows Server 2003.
If I call the procedure within MS SQL Server Management Studio (Version 10.0.2531.0) I get the correct results.
Here is my problem:
If I call the statement from the PHPDriver I get no results.
This seems to be the case whenever I use temporary table variables..
Here is the PHP code:
$dataBaseConnectionInfo = array(
'UID' => $this->loginName,
'PWD' => $this->password,
'Database' => $this->databaseName
);
$serverHandle = sqlsrv_connect(
$this->serverAddress,
$dataBaseConnectionInfo
);
$queryResult = sqlsrv_query($serverHandle, 'EXECUTE test');
$fetchedRows = sqlsrv_fetch_array($queryResult, SQLSRV_FETCH_NUMERIC);
var_dump($fetchedRows);
Thx in advance for any help 🙂
Try adding
SET NOCOUNT ONat the top of the stored procedure