How to call a SQL Server Stored Procedure with PHP

Finally did it.. 🙂

Its as simple as (a+b)(a-b) ;). But the thing is we need to know how to call it exactly( i mean a proper syntax).

As mssql_connect is not supported for php5+, i found some difficulty to find the proper syntax of stored procedures for sqlsrv. Finally the code is here:

$query = “sp_Employee”;
$params = array();
$result1 = sqlsrv_query($conn, $query, $params);
while ($result2 = sqlsrv_fetch_array($result1))
{
echo $result2[Firstname].”<br/>”;
}

Output: list all employees first name in that database 🙂

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s