{"id":8870,"date":"2024-03-05T07:13:42","date_gmt":"2024-03-05T06:13:42","guid":{"rendered":"https:\/\/expert-only.com\/?p=8870"},"modified":"2024-03-05T13:13:53","modified_gmt":"2024-03-05T12:13:53","slug":"how-to-execute-a-procedure-with-parameters-in-sql-server","status":"publish","type":"post","link":"https:\/\/expert-only.com\/en\/t-sql\/how-to-execute-a-procedure-with-parameters-in-sql-server\/","title":{"rendered":"How to Execute a Procedure with Parameters in SQL Server ?"},"content":{"rendered":"\n<h4 class=\"wp-block-heading has-text-align-left\"><em>Tutorial with T-SQL code examples to execute a SQL Server stored procedure with one or multiple input parameters.<\/em><\/h4>\n\n\n\n<p>Depending on the T-SQL code, execute a procedure with parameters in SQL Server by providing mandatory values or default ones will be used. First you must set the value NULL in the procedure code. This is because we create the parameters in a mandatory or a non-mandatory way. For optional parameters, we can assign a default value in the create statement of the SQL procedure. So optional parameters are not stopping from executing the procedure and getting a potential feedback in SSMS.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 ez-toc-wrap-center counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/expert-only.com\/en\/t-sql\/how-to-execute-a-procedure-with-parameters-in-sql-server\/#1-execute-a-sql-server-stored-procedure-with-one-parameter\" >1. Execute a SQL Server stored procedure with one parameter<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/expert-only.com\/en\/t-sql\/how-to-execute-a-procedure-with-parameters-in-sql-server\/#2-run-a-stored-procedure-with-multiple-parameters-in-t-sql\" >2. Run a stored procedure with multiple parameters in T-SQL<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/expert-only.com\/en\/t-sql\/how-to-execute-a-procedure-with-parameters-in-sql-server\/#3-order-matters-when-running-stored-procedures-in-t-sql\" >3. Order matters when running stored procedures in T-SQL<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\" id=\"h-1-execute-a-sql-server-stored-procedure-with-one-parameter\"><span class=\"ez-toc-section\" id=\"1-execute-a-sql-server-stored-procedure-with-one-parameter\"><\/span>1. Execute a SQL Server stored procedure with one parameter<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>First of all, create the procedure to call, or make sure the target is already in the database. If not, execute the code below, it is similar to the used <a href=\"https:\/\/expert-only.com\/en\/t-sql\/create-sql-server-stored-procedure-with-parameters\/\"><strong>to create the uspGetCustomer stored procedure<\/strong><\/a> from this tutorial. In this stored procedure, the unique input parameter is Customer ID, and it is a mandatory one. The goal of the procedure is to display all the information. I.e., all columns from the Clients table for the client number given as a parameter. The sample stored procedure with this script:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"mssql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">CREATE PROCEDURE uspGetCustomer\n   @NoClient INT\nAS\n   SELECT  *\n   FROM    [dbo].[CLIENTS]\n   WHERE   [NOCLIENT] = @NoClient\nGO<\/pre>\n\n\n\n<p>Here is a simple example on how to execute a <a href=\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-stored-procedure\/\"><strong>MS SQL stored procedure<\/strong><\/a> with one or more parameters as input. Indeed, to pass the input information to the SQL code, execute this code and adapt this syntax to the specific business case: <\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"mssql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">EXEC dbo.uspGetCustomer\n   @NoClient = 1;\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-2-run-a-stored-procedure-with-multiple-parameters-in-t-sql\"><span class=\"ez-toc-section\" id=\"2-run-a-stored-procedure-with-multiple-parameters-in-t-sql\"><\/span>2. Run a stored procedure with multiple parameters in T-SQL<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>In this second case, the Client ID and the City are used as parameters. In this more practical examples it is of course possible to use only names and explicit values instead of technical IDs.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"mssql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">-- Create the same procedure with two parameters and also default NULL values\nCREATE PROCEDURE uspGetCustomer\n  @ClientNumber  int          = NULL, \n  @City          nvarchar(20) = NULL\nAS\n  SELECT *\n  FROM   [dbo].[CLIENTS]\n  WHERE  [ClientNumber] = @ClientNumber\n    OR   [City]         = @City\nGO\n<\/pre>\n\n\n\n<p>So to execute a stored procedure coded in SQL Server, simply call the procedure, with the mandatory parameters separated by values, and in the proper order, or named explicitly, which is the recommended way. <\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"mssql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">EXEC dbo.uspGetCustomer\n   @ClientNumber = 2,\n   @City         = 'Casablanca';\n <\/pre>\n\n\n\n<p>Indeed, in the previous paragraph I mention the fac that you do not need to explicitly call the variable names, you can call it this way:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"mssql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">EXEC dbo.uspGetCustomer\n   2,\n   'Casablanca';\n <\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-3-order-matters-when-running-stored-procedures-in-t-sql\"><span class=\"ez-toc-section\" id=\"3-order-matters-when-running-stored-procedures-in-t-sql\"><\/span>3. Order matters when running stored procedures in T-SQL<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>But in this case, the order must be respected. For example, try to run the code below, i.e. without respecting the order.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"mssql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">EXEC dbo.uspGetCustomer\n   'Casablanca', \n   2;\n<\/pre>\n\n\n\n<p>You might encounter a <a href=\"https:\/\/expert-only.com\/en\/errors\/\">SQL Server error<\/a> like this one, because the type of the parameters are not the same. And if they were both integers, it can be worse, because then the result will be false.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"860\" height=\"340\" src=\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/07\/execute-sq-server-stored-procedure-with-parameters-error.jpg\" alt=\"To execute a stored procedure with parameters in SQL Server without error :order must be respected\" class=\"wp-image-29361\" srcset=\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/07\/execute-sq-server-stored-procedure-with-parameters-error.jpg 860w, https:\/\/expert-only.com\/wp-content\/uploads\/2022\/07\/execute-sq-server-stored-procedure-with-parameters-error-300x119.jpg 300w, https:\/\/expert-only.com\/wp-content\/uploads\/2022\/07\/execute-sq-server-stored-procedure-with-parameters-error-768x304.jpg 768w\" sizes=\"auto, (max-width: 860px) 100vw, 860px\" \/><figcaption class=\"wp-element-caption\"><em>To execute a stored procedure with parameters in SQL Server without error :order must be respected<\/em><\/figcaption><\/figure><\/div>\n\n\n<p><em>Msg 8114, Level 16, State 1, Procedure dbo.uspGetCustomer, Line 0 [Batch Start Line 0]<br>Error converting data type varchar to int.<\/em><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-a-simple-syntax-as-long-as-the-parameters-and-default-values-are-used\">A simple syntax as long as the parameters and default values are used<\/h3>\n\n\n\n<p>To go further in the <a href=\"https:\/\/techcrunch.com\/2022\/11\/16\/microsofts-sql-server-2022-is-all-about-azure\/\" target=\"_blank\" rel=\"noreferrer noopener\">SQL Server<\/a> and T-SQL learning journey, this is a short tutorial on <a href=\"https:\/\/expert-only.com\/en\/t-sql\/return-values-sql-server-stored-procedure\/\">how to return values with a stored procedure using the output option<\/a>. Indeed, stored procedures, unlike SQL functions, do not always return a value. To return a value with a MS SQL procedure, use the OUTPUT option.<\/p>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"h-more-content-on-sql-procedures\">More content on SQL Procedures<\/h5>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/expert-only.com\/en\/manage-sql-server-stored-procedures\/\"><strong>Managing SQL Server Stored Procedures<\/strong><\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/expert-only.com\/en\/t-sql\/create-sql-server-stored-procedure-with-parameters\/\">How to create a SQL Server stored procedure with parameters ?<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/expert-only.com\/en\/t-sql\/list-all-sql-server-stored-procedures\/\">How to list all SQL Server Stored Procedures?<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/expert-only.com\/en\/t-sql\/search-text-in-sql-stored-procedure\/\">Searching for text inside a SQL stored procedure<\/a><\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-embed aligncenter is-type-wp-embed is-provider-sql-and-it-tutorials wp-block-embed-sql-and-it-tutorials\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"Z8OZGW8OLU\"><a href=\"https:\/\/expert-only.com\/en\/t-sql\/return-values-sql-server-stored-procedure\/\">Return values with SQL Server stored procedure<\/a><\/blockquote><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;Return values with SQL Server stored procedure&#8221; &#8212; SQL and IT Tutorials\" src=\"https:\/\/expert-only.com\/en\/t-sql\/return-values-sql-server-stored-procedure\/embed\/#?secret=cP04NM2NdO#?secret=Z8OZGW8OLU\" data-secret=\"Z8OZGW8OLU\" width=\"500\" height=\"282\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div><\/figure>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>Tutorial with T-SQL code examples to execute a SQL Server stored procedure with one or multiple input parameters. Depending on the T-SQL code, execute a procedure with parameters in SQL Server by providing mandatory values or default ones will <a class=\"mh-excerpt-more\" href=\"https:\/\/expert-only.com\/en\/t-sql\/how-to-execute-a-procedure-with-parameters-in-sql-server\/\" title=\"How to Execute a Procedure with Parameters in SQL Server ?\">&#8230;<\/a><\/p>\n<\/div>","protected":false},"author":1,"featured_media":6177,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[454],"tags":[],"class_list":{"0":"post-8870","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-t-sql"},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.7 (Yoast SEO v26.2) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Execute a Procedure with Parameters in SQL Server ?<\/title>\n<meta name=\"description\" content=\"To execute a stored procedure with input parameters in SQL Server using a T-SQL query, reuse scripts examples and set mandatory parameters.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/expert-only.com\/en\/t-sql\/how-to-execute-a-procedure-with-parameters-in-sql-server\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Execute a Procedure with Parameters in SQL Server ?\" \/>\n<meta property=\"og:description\" content=\"To execute a stored procedure with input parameters in SQL Server using a T-SQL query, reuse scripts examples and set mandatory parameters.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/expert-only.com\/en\/t-sql\/how-to-execute-a-procedure-with-parameters-in-sql-server\/\" \/>\n<meta property=\"og:site_name\" content=\"SQL and IT Tutorials\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/ExpertOnlyCom\/\" \/>\n<meta property=\"article:published_time\" content=\"2024-03-05T06:13:42+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-03-05T12:13:53+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/07\/texture-design-273B124DF7D_1920x1080.jpeg\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"1080\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Expert-Only\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@expert_only\" \/>\n<meta name=\"twitter:site\" content=\"@expert_only\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Expert-Only\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/how-to-execute-a-procedure-with-parameters-in-sql-server\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/how-to-execute-a-procedure-with-parameters-in-sql-server\/\"},\"author\":{\"name\":\"Expert-Only\",\"@id\":\"https:\/\/expert-only.com\/en\/#\/schema\/person\/406a9576b52944f018739a42046873ef\"},\"headline\":\"How to Execute a Procedure with Parameters in SQL Server ?\",\"datePublished\":\"2024-03-05T06:13:42+00:00\",\"dateModified\":\"2024-03-05T12:13:53+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/how-to-execute-a-procedure-with-parameters-in-sql-server\/\"},\"wordCount\":566,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/expert-only.com\/en\/#organization\"},\"image\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/how-to-execute-a-procedure-with-parameters-in-sql-server\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/07\/texture-design-273B124DF7D_1920x1080.jpeg\",\"articleSection\":[\"T-SQL\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/expert-only.com\/en\/t-sql\/how-to-execute-a-procedure-with-parameters-in-sql-server\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/how-to-execute-a-procedure-with-parameters-in-sql-server\/\",\"url\":\"https:\/\/expert-only.com\/en\/t-sql\/how-to-execute-a-procedure-with-parameters-in-sql-server\/\",\"name\":\"How to Execute a Procedure with Parameters in SQL Server ?\",\"isPartOf\":{\"@id\":\"https:\/\/expert-only.com\/en\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/how-to-execute-a-procedure-with-parameters-in-sql-server\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/how-to-execute-a-procedure-with-parameters-in-sql-server\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/07\/texture-design-273B124DF7D_1920x1080.jpeg\",\"datePublished\":\"2024-03-05T06:13:42+00:00\",\"dateModified\":\"2024-03-05T12:13:53+00:00\",\"description\":\"To execute a stored procedure with input parameters in SQL Server using a T-SQL query, reuse scripts examples and set mandatory parameters.\",\"breadcrumb\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/how-to-execute-a-procedure-with-parameters-in-sql-server\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/expert-only.com\/en\/t-sql\/how-to-execute-a-procedure-with-parameters-in-sql-server\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/how-to-execute-a-procedure-with-parameters-in-sql-server\/#primaryimage\",\"url\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/07\/texture-design-273B124DF7D_1920x1080.jpeg\",\"contentUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/07\/texture-design-273B124DF7D_1920x1080.jpeg\",\"width\":1920,\"height\":1080},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/how-to-execute-a-procedure-with-parameters-in-sql-server\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"en\",\"item\":\"https:\/\/expert-only.com\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Execute a Procedure with Parameters in SQL Server ?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/expert-only.com\/en\/#website\",\"url\":\"https:\/\/expert-only.com\/en\/\",\"name\":\"SQL and IT Tutorials\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/expert-only.com\/en\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/expert-only.com\/en\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/expert-only.com\/en\/#organization\",\"name\":\"Expert-Only\",\"url\":\"https:\/\/expert-only.com\/en\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/expert-only.com\/en\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/09\/cropped-logo_Expert-Only.jpg\",\"contentUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/09\/cropped-logo_Expert-Only.jpg\",\"width\":381,\"height\":174,\"caption\":\"Expert-Only\"},\"image\":{\"@id\":\"https:\/\/expert-only.com\/en\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/ExpertOnlyCom\/\",\"https:\/\/x.com\/expert_only\",\"https:\/\/www.youtube.com\/channel\/UCMS5sR_FwAetB0FmciNvUaA\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/expert-only.com\/en\/#\/schema\/person\/406a9576b52944f018739a42046873ef\",\"name\":\"Expert-Only\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/expert-only.com\/en\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/084b15660763ff5b13bb60b2f52f97bb?s=96&d=identicon&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/084b15660763ff5b13bb60b2f52f97bb?s=96&d=identicon&r=g\",\"caption\":\"Expert-Only\"}}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to Execute a Procedure with Parameters in SQL Server ?","description":"To execute a stored procedure with input parameters in SQL Server using a T-SQL query, reuse scripts examples and set mandatory parameters.","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:\/\/expert-only.com\/en\/t-sql\/how-to-execute-a-procedure-with-parameters-in-sql-server\/","og_locale":"en_US","og_type":"article","og_title":"How to Execute a Procedure with Parameters in SQL Server ?","og_description":"To execute a stored procedure with input parameters in SQL Server using a T-SQL query, reuse scripts examples and set mandatory parameters.","og_url":"https:\/\/expert-only.com\/en\/t-sql\/how-to-execute-a-procedure-with-parameters-in-sql-server\/","og_site_name":"SQL and IT Tutorials","article_publisher":"https:\/\/www.facebook.com\/ExpertOnlyCom\/","article_published_time":"2024-03-05T06:13:42+00:00","article_modified_time":"2024-03-05T12:13:53+00:00","og_image":[{"width":1920,"height":1080,"url":"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/07\/texture-design-273B124DF7D_1920x1080.jpeg","type":"image\/jpeg"}],"author":"Expert-Only","twitter_card":"summary_large_image","twitter_creator":"@expert_only","twitter_site":"@expert_only","twitter_misc":{"Written by":"Expert-Only","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/expert-only.com\/en\/t-sql\/how-to-execute-a-procedure-with-parameters-in-sql-server\/#article","isPartOf":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/how-to-execute-a-procedure-with-parameters-in-sql-server\/"},"author":{"name":"Expert-Only","@id":"https:\/\/expert-only.com\/en\/#\/schema\/person\/406a9576b52944f018739a42046873ef"},"headline":"How to Execute a Procedure with Parameters in SQL Server ?","datePublished":"2024-03-05T06:13:42+00:00","dateModified":"2024-03-05T12:13:53+00:00","mainEntityOfPage":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/how-to-execute-a-procedure-with-parameters-in-sql-server\/"},"wordCount":566,"commentCount":0,"publisher":{"@id":"https:\/\/expert-only.com\/en\/#organization"},"image":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/how-to-execute-a-procedure-with-parameters-in-sql-server\/#primaryimage"},"thumbnailUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/07\/texture-design-273B124DF7D_1920x1080.jpeg","articleSection":["T-SQL"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/expert-only.com\/en\/t-sql\/how-to-execute-a-procedure-with-parameters-in-sql-server\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/expert-only.com\/en\/t-sql\/how-to-execute-a-procedure-with-parameters-in-sql-server\/","url":"https:\/\/expert-only.com\/en\/t-sql\/how-to-execute-a-procedure-with-parameters-in-sql-server\/","name":"How to Execute a Procedure with Parameters in SQL Server ?","isPartOf":{"@id":"https:\/\/expert-only.com\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/how-to-execute-a-procedure-with-parameters-in-sql-server\/#primaryimage"},"image":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/how-to-execute-a-procedure-with-parameters-in-sql-server\/#primaryimage"},"thumbnailUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/07\/texture-design-273B124DF7D_1920x1080.jpeg","datePublished":"2024-03-05T06:13:42+00:00","dateModified":"2024-03-05T12:13:53+00:00","description":"To execute a stored procedure with input parameters in SQL Server using a T-SQL query, reuse scripts examples and set mandatory parameters.","breadcrumb":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/how-to-execute-a-procedure-with-parameters-in-sql-server\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/expert-only.com\/en\/t-sql\/how-to-execute-a-procedure-with-parameters-in-sql-server\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/expert-only.com\/en\/t-sql\/how-to-execute-a-procedure-with-parameters-in-sql-server\/#primaryimage","url":"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/07\/texture-design-273B124DF7D_1920x1080.jpeg","contentUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/07\/texture-design-273B124DF7D_1920x1080.jpeg","width":1920,"height":1080},{"@type":"BreadcrumbList","@id":"https:\/\/expert-only.com\/en\/t-sql\/how-to-execute-a-procedure-with-parameters-in-sql-server\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"en","item":"https:\/\/expert-only.com\/en\/"},{"@type":"ListItem","position":2,"name":"How to Execute a Procedure with Parameters in SQL Server ?"}]},{"@type":"WebSite","@id":"https:\/\/expert-only.com\/en\/#website","url":"https:\/\/expert-only.com\/en\/","name":"SQL and IT Tutorials","description":"","publisher":{"@id":"https:\/\/expert-only.com\/en\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/expert-only.com\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/expert-only.com\/en\/#organization","name":"Expert-Only","url":"https:\/\/expert-only.com\/en\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/expert-only.com\/en\/#\/schema\/logo\/image\/","url":"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/09\/cropped-logo_Expert-Only.jpg","contentUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/09\/cropped-logo_Expert-Only.jpg","width":381,"height":174,"caption":"Expert-Only"},"image":{"@id":"https:\/\/expert-only.com\/en\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/ExpertOnlyCom\/","https:\/\/x.com\/expert_only","https:\/\/www.youtube.com\/channel\/UCMS5sR_FwAetB0FmciNvUaA"]},{"@type":"Person","@id":"https:\/\/expert-only.com\/en\/#\/schema\/person\/406a9576b52944f018739a42046873ef","name":"Expert-Only","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/expert-only.com\/en\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/084b15660763ff5b13bb60b2f52f97bb?s=96&d=identicon&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/084b15660763ff5b13bb60b2f52f97bb?s=96&d=identicon&r=g","caption":"Expert-Only"}}]}},"_links":{"self":[{"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/posts\/8870","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/comments?post=8870"}],"version-history":[{"count":14,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/posts\/8870\/revisions"}],"predecessor-version":[{"id":30520,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/posts\/8870\/revisions\/30520"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/media\/6177"}],"wp:attachment":[{"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/media?parent=8870"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/categories?post=8870"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/tags?post=8870"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}