{"id":4434,"date":"2024-07-31T10:39:53","date_gmt":"2024-07-31T03:39:53","guid":{"rendered":"https:\/\/www.sqlservertutorial.net\/?page_id=4434"},"modified":"2024-08-18T10:16:42","modified_gmt":"2024-08-18T03:16:42","slug":"php-sql-server-call-stored-procedure","status":"publish","type":"page","link":"https:\/\/www.sqlservertutorial.net\/php-sql-server\/php-sql-server-call-stored-procedure\/","title":{"rendered":"PHP SQL Server: Calling Stored Procedures"},"content":{"rendered":"\n<p><strong>Summary<\/strong>: in this tutorial, you will learn how to call a stored procedure from SQL Server using PHP.<\/p>\n\n\n\n<p class=\"note\">This tutorial begins where\u00a0<a href=\"https:\/\/www.sqlservertutorial.net\/php-sql-server\/php-sql-server-transaction\/\">performing a transaction using PHP tutorial<\/a>\u00a0left off.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='creating-a-stored-procedure'>Creating a stored procedure <a href=\"#creating-a-stored-procedure\" class=\"anchor\" id=\"creating-a-stored-procedure\" title=\"Anchor for Creating a stored procedure\">#<\/a><\/h2>\n\n\n\n<p>Step 1. Launch the  SQL Server Management Studio (SSMS) and connect to the <code>BookStore<\/code> database.<\/p>\n\n\n\n<p>Step 2. Execute the  following statement to create a new stored procedure that retrieves authors by birth date between start and end dates:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">CREATE<\/span> <span class=\"hljs-keyword\">PROCEDURE<\/span> GetAuthorsByBirthDate\n    @StartDate <span class=\"hljs-built_in\">DATE<\/span>,\n    @EndDate <span class=\"hljs-built_in\">DATE<\/span>\n<span class=\"hljs-keyword\">AS<\/span>\n<span class=\"hljs-keyword\">BEGIN<\/span>\n    <span class=\"hljs-keyword\">SET<\/span> NOCOUNT <span class=\"hljs-keyword\">ON<\/span>;\n\n    <span class=\"hljs-keyword\">SELECT<\/span> \n        AuthorID,\n        FirstName,\n        LastName,\n        BirthDate\n    <span class=\"hljs-keyword\">FROM<\/span> \n        <span class=\"hljs-keyword\">Authors<\/span>\n    <span class=\"hljs-keyword\">WHERE<\/span> \n        BirthDate <span class=\"hljs-keyword\">BETWEEN<\/span> @StartDate <span class=\"hljs-keyword\">AND<\/span> @EndDate\n    <span class=\"hljs-keyword\">ORDER<\/span> <span class=\"hljs-keyword\">BY<\/span> \n        BirthDate;\n<span class=\"hljs-keyword\">END<\/span>;\nGO<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\" id='calling-the-stored-procedure-from-php'>Calling the stored procedure from PHP <a href=\"#calling-the-stored-procedure-from-php\" class=\"anchor\" id=\"calling-the-stored-procedure-from-php\" title=\"Anchor for Calling the stored procedure from PHP\">#<\/a><\/h2>\n\n\n\n<p>Define a method <code>findAuthorsByBirthDate<\/code> in the <code>AuthorDB<\/code> class to call the <code>GetAuthorsByBirthDate<\/code> stored procedure:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">findAuthorsByBirthDate<\/span><span class=\"hljs-params\">($startDate, $endDate)<\/span>\n<\/span>{\n    $authors = &#91;];\n\n    <span class=\"hljs-keyword\">try<\/span> {\n        $stmt = <span class=\"hljs-keyword\">$this<\/span>-&gt;conn-&gt;prepare(<span class=\"hljs-string\">\"EXEC GetAuthorsByBirthDate :startDate, :endDate\"<\/span>);\n        $stmt-&gt;bindParam(<span class=\"hljs-string\">':startDate'<\/span>, $startDate);\n        $stmt-&gt;bindParam(<span class=\"hljs-string\">':endDate'<\/span>, $endDate);\n\n        $stmt-&gt;execute();\n\n        <span class=\"hljs-keyword\">while<\/span> ($row = $stmt-&gt;fetch(PDO::FETCH_ASSOC)) {\n            $authors&#91;] = <span class=\"hljs-keyword\">new<\/span> Author(\n                $row&#91;<span class=\"hljs-string\">'FirstName'<\/span>],\n                $row&#91;<span class=\"hljs-string\">'LastName'<\/span>],\n                $row&#91;<span class=\"hljs-string\">'BirthDate'<\/span>],\n                $row&#91;<span class=\"hljs-string\">'AuthorID'<\/span>]\n            );\n        }\n    } <span class=\"hljs-keyword\">catch<\/span> (PDOException $e) {\n        <span class=\"hljs-keyword\">throw<\/span> <span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-keyword\">Exception<\/span>(<span class=\"hljs-string\">\"Error fetching authors: \"<\/span> . $e-&gt;getMessage());\n    }\n\n    <span class=\"hljs-keyword\">return<\/span> $authors;\n}<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>How it works.<\/p>\n\n\n\n<p>Step 1. Define a public method <code>findAuthorsByBirthDate<\/code> that finds authors with the birth dates between start and end dates:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">findAuthorsByBirthDate<\/span><span class=\"hljs-params\">($startDate, $endDate)<\/span><\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Step 2. Initialize an array to store the <code>Author<\/code> objects created from the data of the <code>Authors<\/code> table:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">$authors = &#91;];<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Step 3. Create a prepared statement that executes a call to the <code>GetAuthorsByBirthDate<\/code> stored procedure.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">$stmt = <span class=\"hljs-keyword\">$this<\/span>-&gt;conn-&gt;prepare(<span class=\"hljs-string\">\"EXEC GetAuthorsByBirthDate :startDate, :endDate\"<\/span>);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The <code>:startDate<\/code> and <code>:endDate<\/code> are placeholders for query parameters, which help prevent SQL injections.<\/p>\n\n\n\n<p>Step 4. Bind the values for the <code>:startDate<\/code> and <code>:endDate<\/code> parameters:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">$stmt-&gt;bindParam(<span class=\"hljs-string\">':startDate'<\/span>, $startDate);\n$stmt-&gt;bindParam(<span class=\"hljs-string\">':endDate'<\/span>, $endDate);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Step 5. Execute the prepared statement by calling the execute() method:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">$stmt-&gt;execute();<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Step 6. Fetch rows, create an Author for each row, and add it to the $authors array:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-keyword\">while<\/span> ($row = $stmt-&gt;fetch(PDO::FETCH_ASSOC)) {\n   $authors&#91;] = <span class=\"hljs-keyword\">new<\/span> Author(\n                $row&#91;<span class=\"hljs-string\">'FirstName'<\/span>],\n                $row&#91;<span class=\"hljs-string\">'LastName'<\/span>],\n                $row&#91;<span class=\"hljs-string\">'BirthDate'<\/span>],\n                $row&#91;<span class=\"hljs-string\">'AuthorID'<\/span>]\n            );\n}<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Step 7. Return the $authors array:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-keyword\">return<\/span> $authors<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\" id='running-the-app'>Running the app <a href=\"#running-the-app\" class=\"anchor\" id=\"running-the-app\" title=\"Anchor for Running the app\">#<\/a><\/h2>\n\n\n\n<p>Modify the <code>index.php<\/code> file to call the <code>findAuthorsByBirthDate<\/code> method:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-10\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-meta\">&lt;?php<\/span>\n\n<span class=\"hljs-keyword\">require_once<\/span> <span class=\"hljs-string\">'authordb.php'<\/span>;\n\n<span class=\"hljs-comment\">\/\/ Connect to the SQL Server<\/span>\n$conn = <span class=\"hljs-keyword\">require_once<\/span> <span class=\"hljs-string\">'connect.php'<\/span>;\n\n$authorDB = <span class=\"hljs-keyword\">new<\/span> AuthorDB($conn);\n\n<span class=\"hljs-comment\">\/\/ Find authors between birth dates<\/span>\n$authors = $authorDB-&gt;findAuthorsByBirthDate(<span class=\"hljs-string\">'1980-01-01'<\/span>, <span class=\"hljs-string\">'1986-12-31'<\/span>);\n\n<span class=\"hljs-keyword\">foreach<\/span> ($authors <span class=\"hljs-keyword\">as<\/span> $author) {\n    <span class=\"hljs-keyword\">echo<\/span> $author-&gt;getFirstName() . <span class=\"hljs-string\">' '<\/span> .\n         $author-&gt;getLastName() . <span class=\"hljs-string\">' : '<\/span> .\n         $author-&gt;getBirthDate() . <span class=\"hljs-string\">'&lt;br&gt;'<\/span>;\n}<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-10\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Output:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-11\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">Donna Bailey : <span class=\"hljs-number\">1980<\/span><span class=\"hljs-number\">-11<\/span><span class=\"hljs-number\">-20<\/span>\nLisa Savage : <span class=\"hljs-number\">1981<\/span><span class=\"hljs-number\">-04<\/span><span class=\"hljs-number\">-13<\/span>\nDavid Hunter : <span class=\"hljs-number\">1983<\/span><span class=\"hljs-number\">-08<\/span><span class=\"hljs-number\">-01<\/span>\nKaren Simmons : <span class=\"hljs-number\">1986<\/span><span class=\"hljs-number\">-06<\/span><span class=\"hljs-number\">-19<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-11\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>How it works.<\/p>\n\n\n\n<p>First, load the <code>authordb.php<\/code> file to use the <code>AuthorDB<\/code> class.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-12\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-keyword\">require_once<\/span> <span class=\"hljs-string\">'authordb.php'<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-12\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Second, <a href=\"https:\/\/www.sqlservertutorial.net\/php-sql-server\/php-connect-to-sql-server\/\">connect to the SQL Server<\/a> and assign the returned PDO object to the <code>$conn<\/code> variable:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-13\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">$conn = <span class=\"hljs-keyword\">require_once<\/span> <span class=\"hljs-string\">'connect.php'<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-13\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Third, create a new <code>AuthorDB<\/code> object:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-14\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">$authorDB = <span class=\"hljs-keyword\">new<\/span> AuthorDB($conn);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-14\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Fourth, call the <code>findAuthorsByBirthDate()<\/code> method to retrieve authors whose birth dates are between <code>'1980-01-01'<\/code> and <code>'1986-12-31'<\/code>:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-15\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">$authors = $authorDB-&gt;findAuthorsByBirthDate(<span class=\"hljs-string\">'1980-01-01'<\/span>, <span class=\"hljs-string\">'1986-12-31'<\/span>);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-15\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Finally, display author&#8217;s information:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-16\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-keyword\">foreach<\/span> ($authors <span class=\"hljs-keyword\">as<\/span> $author) {\n    <span class=\"hljs-keyword\">echo<\/span> $author-&gt;getFirstName() . <span class=\"hljs-string\">' '<\/span> .\n         $author-&gt;getLastName() . <span class=\"hljs-string\">' : '<\/span> .\n         $author-&gt;getBirthDate() . <span class=\"hljs-string\">'&lt;br&gt;'<\/span>;\n}<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-16\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\" id='summary'>Summary <a href=\"#summary\" class=\"anchor\" id=\"summary\" title=\"Anchor for Summary\">#<\/a><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Execute the <code>EXEC<\/code> statement to call a stored procedure from SQL Server in PHP.<\/li>\n<\/ul>\n<div class=\"helpful-block-content\" data-title=\"\">\n\t<header>\n\t\t<div class=\"wth-question\">Was this tutorial helpful?<\/div>\n\t\t<div class=\"wth-thumbs\">\n\t\t\t<button\n\t\t\t\tdata-post=\"4434\"\n\t\t\t\tdata-post-url=\"https:\/\/www.sqlservertutorial.net\/php-sql-server\/php-sql-server-call-stored-procedure\/\"\n\t\t\t\tdata-post-title=\"PHP SQL Server: Calling Stored Procedures\"\n\t\t\t\tdata-response=\"1\"\n\t\t\t\tclass=\"wth-btn-rounded wth-yes-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t\tclass=\"feather feather-thumbs-up block w-full h-full\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> Yes <\/span>\n\t\t\t<\/button>\n\n\t\t\t<button\n\t\t\t\tdata-response=\"0\"\n\t\t\t\tdata-post=\"4434\"\n\t\t\t\tdata-post-url=\"https:\/\/www.sqlservertutorial.net\/php-sql-server\/php-sql-server-call-stored-procedure\/\"\n\t\t\t\tdata-post-title=\"PHP SQL Server: Calling Stored Procedures\"\n\t\t\t\tclass=\"wth-btn-rounded wth-no-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> No <\/span>\n\t\t\t<\/button>\n\t\t<\/div>\n\t<\/header>\n\n\t<div class=\"wth-form hidden\">\n\t\t<div class=\"wth-form-wrapper\">\n\t\t\t<div class=\"wth-title\"><\/div>\n\t\t\t\n\t\t\t<textarea class=\"wth-message\"><\/textarea>\n\n\t\t\t<button class=\"btn btn-primary wth-btn-submit\">Send<\/button>\n\t\t\t<button class=\"btn wth-btn-cancel\">Cancel<\/button>\n\t\t\n\t\t<\/div>\n\t<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, you will learn how to call a stored procedure from SQL Server using PHP.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":4375,"menu_order":8,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-4434","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>PHP SQL Server: Call Stored Procedure<\/title>\n<meta name=\"description\" content=\"In this tutorial, you will learn how to call a stored procedure from SQL Server using PHP.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.sqlservertutorial.net\/php-sql-server\/php-sql-server-call-stored-procedure\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PHP SQL Server: Call Stored Procedure\" \/>\n<meta property=\"og:description\" content=\"In this tutorial, you will learn how to call a stored procedure from SQL Server using PHP.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqlservertutorial.net\/php-sql-server\/php-sql-server-call-stored-procedure\/\" \/>\n<meta property=\"og:site_name\" content=\"SQL Server Tutorial\" \/>\n<meta property=\"article:modified_time\" content=\"2024-08-18T03:16:42+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/php-sql-server\\\/php-sql-server-call-stored-procedure\\\/\",\"url\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/php-sql-server\\\/php-sql-server-call-stored-procedure\\\/\",\"name\":\"PHP SQL Server: Call Stored Procedure\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/#website\"},\"datePublished\":\"2024-07-31T03:39:53+00:00\",\"dateModified\":\"2024-08-18T03:16:42+00:00\",\"description\":\"In this tutorial, you will learn how to call a stored procedure from SQL Server using PHP.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/php-sql-server\\\/php-sql-server-call-stored-procedure\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.sqlservertutorial.net\\\/php-sql-server\\\/php-sql-server-call-stored-procedure\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/php-sql-server\\\/php-sql-server-call-stored-procedure\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PHP SQL Server\",\"item\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/php-sql-server\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"PHP SQL Server: Calling Stored Procedures\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/#website\",\"url\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/\",\"name\":\"SQL Server Tutorial\",\"description\":\"The Practical SQL Server Tutorial\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"PHP SQL Server: Call Stored Procedure","description":"In this tutorial, you will learn how to call a stored procedure from SQL Server using PHP.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.sqlservertutorial.net\/php-sql-server\/php-sql-server-call-stored-procedure\/","og_locale":"en_US","og_type":"article","og_title":"PHP SQL Server: Call Stored Procedure","og_description":"In this tutorial, you will learn how to call a stored procedure from SQL Server using PHP.","og_url":"https:\/\/www.sqlservertutorial.net\/php-sql-server\/php-sql-server-call-stored-procedure\/","og_site_name":"SQL Server Tutorial","article_modified_time":"2024-08-18T03:16:42+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.sqlservertutorial.net\/php-sql-server\/php-sql-server-call-stored-procedure\/","url":"https:\/\/www.sqlservertutorial.net\/php-sql-server\/php-sql-server-call-stored-procedure\/","name":"PHP SQL Server: Call Stored Procedure","isPartOf":{"@id":"https:\/\/www.sqlservertutorial.net\/#website"},"datePublished":"2024-07-31T03:39:53+00:00","dateModified":"2024-08-18T03:16:42+00:00","description":"In this tutorial, you will learn how to call a stored procedure from SQL Server using PHP.","breadcrumb":{"@id":"https:\/\/www.sqlservertutorial.net\/php-sql-server\/php-sql-server-call-stored-procedure\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqlservertutorial.net\/php-sql-server\/php-sql-server-call-stored-procedure\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqlservertutorial.net\/php-sql-server\/php-sql-server-call-stored-procedure\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqlservertutorial.net\/"},{"@type":"ListItem","position":2,"name":"PHP SQL Server","item":"https:\/\/www.sqlservertutorial.net\/php-sql-server\/"},{"@type":"ListItem","position":3,"name":"PHP SQL Server: Calling Stored Procedures"}]},{"@type":"WebSite","@id":"https:\/\/www.sqlservertutorial.net\/#website","url":"https:\/\/www.sqlservertutorial.net\/","name":"SQL Server Tutorial","description":"The Practical SQL Server Tutorial","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.sqlservertutorial.net\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/pages\/4434","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/comments?post=4434"}],"version-history":[{"count":5,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/pages\/4434\/revisions"}],"predecessor-version":[{"id":4511,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/pages\/4434\/revisions\/4511"}],"up":[{"embeddable":true,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/pages\/4375"}],"wp:attachment":[{"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/media?parent=4434"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}