sql server 2008 - Get the resultset of a function with sqlsrv and PHP


I have a function in my SQL Server 2008 thats return a resulset and some output variables.

From PHP, i need get the values with sqlsrv library.

I have this code, which I tested with a stored procedure and work fine.


$serverName = "(local)\MSSQLSERVER, 1433";

$connectionInfo = array(

$conn = sqlsrv_connect($serverName, $connectionInfo);

if(!$conn) {

$tsql_callSP = "{call my_function(?, ?)}";

$ret_cod = "";
$ret_desc = "";

$params = array( 
    array($ret_cod, SQLSRV_PARAM_OUT),
    array($ret_desc, SQLSRV_PARAM_OUT)

$stmt = sqlsrv_query( $conn, $tsql_callSP, $params);

if( $stmt === false )
     debug("Error in executing statement");
     die( debug( sqlsrv_errors(), true));

The result of error is:

[Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Error en la solicitud procedimiento 'my_function'. 'my_function' es un objeto funciĆ³n con valores de tabla

Is a sintaxis error i know, but i dont find examples on internet of how to do this.

I try,

$tsql_callSP = "? = {call my_function(?, ?)}";

And similar but dont works.

Any ideas?.

Thanks you.

People are also looking for solutions to the problem: php - How do I change this example Facebook code to post feed data automatically?


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.