{"id":8833,"date":"2023-11-16T07:41:00","date_gmt":"2023-11-16T06:41:00","guid":{"rendered":"https:\/\/expert-only.com\/?p=8833"},"modified":"2023-11-23T12:07:53","modified_gmt":"2023-11-23T11:07:53","slug":"create-sql-server-stored-procedure-with-parameters","status":"publish","type":"post","link":"https:\/\/expert-only.com\/en\/t-sql\/create-sql-server-stored-procedure-with-parameters\/","title":{"rendered":"How to create a SQL Server stored procedure with parameters ?"},"content":{"rendered":"\n<h4 class=\"wp-block-heading has-text-align-left\"><em>T-SQL tutorial to create a SQL Server stored procedure with input parameters and T-SQL variables.<\/em><\/h4>\n\n\n\n<p>Create a SQL Server stored procedure with parameters and default values. The goal of SQL procedures is to group and schedule a set of SQL or T-SQL commands. But how to integrate a dynamic SELECT query on the Customers table of a SQL Server database into a stored procedure?<\/p>\n\n\n\n<p>For example, instead of displaying all the data from the table, display a single customer. We need to filter the table using the parameter value passed as an input hard coded value or variable. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Create the sample table<\/h3>\n\n\n\n<p>Before running the script to create the stored procedure, create the clients table first. Indeed, use this SQL Server script to create the Clients table with a simple structure and 3 columns: <\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>ClientNumber<\/li>\n\n\n\n<li>Name<\/li>\n\n\n\n<li>City<\/li>\n<\/ol>\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 clients table to store the number, the name and the city\nCREATE TABLE [dbo].[CLIENTS] (\n   [ClientNumber]  int IDENTITY(1,1),\n   [Name]          nvarchar(20) UNIQUE,\n   [City]          nvarchar(20)\n)\nGO<\/pre>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"640\" height=\"263\" src=\"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/08\/sql-server-exemple-table-clients.png\" alt=\"SQL Server query to display the contents of the CLIENTS table\" class=\"wp-image-4285\" srcset=\"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/08\/sql-server-exemple-table-clients.png 640w, https:\/\/expert-only.com\/wp-content\/uploads\/2017\/08\/sql-server-exemple-table-clients-300x123.png 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><figcaption class=\"wp-element-caption\"><em>SQL Server query to display the contents of the CLIENTS table<\/em><\/figcaption><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-1-t-sql-code-to-create-a-procedure-with-one-parameter\">1. T-SQL code to create a procedure with one parameter<\/h2>\n\n\n\n<p>This is an example of a SQL stored procedure that uses a single parameter. This parameter is the customer number. The procedure displays the customer whose number is passed as a parameter.<\/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 uspGetClient\n@NoClient INT\nAS\n\tSELECT \t*\n\tFROM \t[dbo].[CLIENTS]\n\tWHERE \t[NOCLIENT] = @NoClient\nGO\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">2. Call the stored procedure using EXEC or EXECUTE<\/h2>\n\n\n\n<p>To call the stored procedure, execute the code as follows with EXEC or EXECUTE :<\/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 uspGetClient @NoClient = 3;\n\nEXECUTE uspGetClient @NoClient = 3;\n<\/pre>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"665\" height=\"304\" src=\"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/08\/procedure-stockee-sql-server-un-parametre.png\" alt=\"Manage SQL Server stored procedure parameters with variables\" class=\"wp-image-4283\" srcset=\"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/08\/procedure-stockee-sql-server-un-parametre.png 665w, https:\/\/expert-only.com\/wp-content\/uploads\/2017\/08\/procedure-stockee-sql-server-un-parametre-300x137.png 300w\" sizes=\"auto, (max-width: 665px) 100vw, 665px\" \/><figcaption class=\"wp-element-caption\"><strong>Manage SQL Server stored procedure parameters with variables<\/strong><\/figcaption><\/figure><\/div>\n\n\n<p>In the previous example, the procedure call passes the value of the parameter. Similarly, execute the SQL Server procedure without passing the @NoClient parameter value:<\/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 uspGetClient;\n<\/pre>\n\n\n\n<p>Then the following SQL error message is displayed because the client number parameter is mandatory and is not assigned a default value:<\/p>\n\n\n\n<p><em>Procedure or function &#8216;uspGetClient&#8217; expects parameter &#8216;@NoClient&#8217;, which was not supplied.<\/em><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-3-manage-parameters-default-values-in-stored-procedure\">3. Manage parameters default values in stored procedure<\/h2>\n\n\n\n<p>To go further and manage the default values, it is simple, in most cases, it is advisable to pass a value to the parameters. In practice, this is not always possible or even useful. To foresee the case where a call to the procedure is made without parameters, use the NULL value. Indeed NULL allows to initialize a parameter value in the procedure and to avoid errors.<\/p>\n\n\n\n<p>After that, execute this second version of the stored procedure without parameters. This time, no errors and the query return no rows because all the clients in the table have a client number.<\/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=\"\">-- Test if the procedure exists and delete it\nIF EXISTS (\n   SELECT name \n   FROM sysobjects \n   WHERE name = 'uspGetClient' AND type = 'P'\n)\n  DROP PROCEDURE uspGetClient\nGO\n\n-- Create the stored procedure with a default value\nCREATE PROCEDURE uspGetClient \n  @NoClient int = NULL\nAS\n  SELECT   *\n  FROM   [dbo].[CLIENTS]\n  WHERE   [NOCLIENT] = @NoClient\nGO\n\n-- Execute the stored procedure without passing any parameters\nEXEC uspGetClient;\n<\/pre>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"729\" height=\"355\" src=\"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/08\/procedure-sql-server-parametre-defaut-null.png\" alt=\"Delete, create, and execute a SQL Server stored procedure without using parameters\" class=\"wp-image-4287\" srcset=\"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/08\/procedure-sql-server-parametre-defaut-null.png 729w, https:\/\/expert-only.com\/wp-content\/uploads\/2017\/08\/procedure-sql-server-parametre-defaut-null-300x146.png 300w\" sizes=\"auto, (max-width: 729px) 100vw, 729px\" \/><figcaption class=\"wp-element-caption\">Delete, create, and execute a SQL Server stored procedure without using parameters<\/figcaption><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-4-sql-server-stored-procedure-with-multiple-parameters\">4. SQL Server stored procedure with multiple parameters<\/h2>\n\n\n\n<p>This is the same principle as with a single parameter, and each parameter must be listed, initialized, and called independently. Thus, enumerate and separate each parameter and its data type with a comma, as in this example of SQL code:<\/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=\"\">-- Test if the procedure exists and delete it\nIF EXISTS (\n   SELECT name \n   FROM \tsysobjects \n   WHERE \tname = 'uspGetClient' AND type = 'P'\n)\n  DROP PROCEDURE uspGetClient\nGO\n\n-- Create the same procedure with two parameters and default values\nCREATE PROCEDURE uspGetClient \n  @ClientNumber   \tint = NULL, \n  @City   \t\tnvarchar(20) = NULL\nAS\n  SELECT   *\n  FROM   \t[dbo].[CLIENTS]\n  WHERE  \t[ClientNumber]  = @ClientNumber\n    OR   \t[City]      = @City\nGO\n\n-- Call the procedure with different parameter combinations\nEXEC uspGetClient @ClientNumber = 1, @City = 'Lyon';\n\nEXEC uspGetClient @ClientNumber = 1;\n\nEXEC uspGetClient @City = 'Paris';\n<\/pre>\n\n\n\n<p>Indeed, one can call each of the parameters alone, or both simultaneously. It is possible to pass no parameters because the procedure initializes the default values with the value NULL.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"681\" height=\"559\" src=\"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/08\/procedure-sql-server-plusieurs-parametres.png\" alt=\"Delete, create, and execute a SQL Server stored procedure with parameters.\" class=\"wp-image-4289\" srcset=\"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/08\/procedure-sql-server-plusieurs-parametres.png 681w, https:\/\/expert-only.com\/wp-content\/uploads\/2017\/08\/procedure-sql-server-plusieurs-parametres-300x246.png 300w\" sizes=\"auto, (max-width: 681px) 100vw, 681px\" \/><figcaption class=\"wp-element-caption\">Delete, create, and execute a SQL Server stored procedure with parameters.<\/figcaption><\/figure><\/div>\n\n\n<h3 class=\"wp-block-heading\" id=\"h-sql-procedures-with-parameters-allow-flexible-code\">SQL procedures with parameters allow flexible code<\/h3>\n\n\n\n<p>Finally, calling the <em>uspGetClient<\/em> stored procedure without parameters is possible. In this case, it returns all the data contained in the Clients table because the logical OR operator is used in the WHERE clause. This scripts simply displays data from a customers table, however stored procedures can also be used to manipulate objects, like creating and rebuilding <a href=\"https:\/\/docs.microsoft.com\/en-us\/sql\/t-sql\/statements\/create-index-transact-sql?view=sql-server-ver16\" target=\"_blank\" rel=\"noreferrer noopener\">indexes<\/a>.<\/p>\n\n\n\n<p>To continue learning, this other tutorial explains step by step how to <strong><a href=\"https:\/\/expert-only.com\/en\/t-sql\/alter-sql-server-stored-procedure\/\">alter a SQL Server stored procedure<\/a><\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-embed 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=\"p3n7BfzvWJ\"><a href=\"https:\/\/expert-only.com\/en\/t-sql\/alter-sql-server-stored-procedure\/\">How To Alter A 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;How To Alter A SQL Server Stored Procedure ?&#8221; &#8212; SQL and IT Tutorials\" src=\"https:\/\/expert-only.com\/en\/t-sql\/alter-sql-server-stored-procedure\/embed\/#?secret=2A2MEcHlMa#?secret=p3n7BfzvWJ\" data-secret=\"p3n7BfzvWJ\" 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>T-SQL tutorial to create a SQL Server stored procedure with input parameters and T-SQL variables. Create a SQL Server stored procedure with parameters and default values. The goal of SQL procedures is to group and schedule a set of <a class=\"mh-excerpt-more\" href=\"https:\/\/expert-only.com\/en\/t-sql\/create-sql-server-stored-procedure-with-parameters\/\" title=\"How to create a SQL Server stored procedure with parameters ?\">&#8230;<\/a><\/p>\n<\/div>","protected":false},"author":1,"featured_media":5811,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[454],"tags":[],"class_list":{"0":"post-8833","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 create a SQL Server stored procedure with parameters ?<\/title>\n<meta name=\"description\" content=\"Tutorial with scripts to create and execute a SQL Server stored procedure with parameters and assign a default values to input variables.\" \/>\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\/create-sql-server-stored-procedure-with-parameters\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to create a SQL Server stored procedure with parameters ?\" \/>\n<meta property=\"og:description\" content=\"Tutorial with scripts to create and execute a SQL Server stored procedure with parameters and assign a default values to input variables.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/expert-only.com\/en\/t-sql\/create-sql-server-stored-procedure-with-parameters\/\" \/>\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=\"2023-11-16T06:41:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-11-23T11:07:53+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/08\/inspiration_dark_new-york-city-F323EDDD185_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=\"4 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\/create-sql-server-stored-procedure-with-parameters\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/create-sql-server-stored-procedure-with-parameters\/\"},\"author\":{\"name\":\"Expert-Only\",\"@id\":\"https:\/\/expert-only.com\/en\/#\/schema\/person\/406a9576b52944f018739a42046873ef\"},\"headline\":\"How to create a SQL Server stored procedure with parameters ?\",\"datePublished\":\"2023-11-16T06:41:00+00:00\",\"dateModified\":\"2023-11-23T11:07:53+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/create-sql-server-stored-procedure-with-parameters\/\"},\"wordCount\":582,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/expert-only.com\/en\/#organization\"},\"image\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/create-sql-server-stored-procedure-with-parameters\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/08\/inspiration_dark_new-york-city-F323EDDD185_1920x1080.jpeg\",\"articleSection\":[\"T-SQL\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/expert-only.com\/en\/t-sql\/create-sql-server-stored-procedure-with-parameters\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/create-sql-server-stored-procedure-with-parameters\/\",\"url\":\"https:\/\/expert-only.com\/en\/t-sql\/create-sql-server-stored-procedure-with-parameters\/\",\"name\":\"How to create a SQL Server stored procedure with parameters ?\",\"isPartOf\":{\"@id\":\"https:\/\/expert-only.com\/en\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/create-sql-server-stored-procedure-with-parameters\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/create-sql-server-stored-procedure-with-parameters\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/08\/inspiration_dark_new-york-city-F323EDDD185_1920x1080.jpeg\",\"datePublished\":\"2023-11-16T06:41:00+00:00\",\"dateModified\":\"2023-11-23T11:07:53+00:00\",\"description\":\"Tutorial with scripts to create and execute a SQL Server stored procedure with parameters and assign a default values to input variables.\",\"breadcrumb\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/create-sql-server-stored-procedure-with-parameters\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/expert-only.com\/en\/t-sql\/create-sql-server-stored-procedure-with-parameters\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/create-sql-server-stored-procedure-with-parameters\/#primaryimage\",\"url\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/08\/inspiration_dark_new-york-city-F323EDDD185_1920x1080.jpeg\",\"contentUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/08\/inspiration_dark_new-york-city-F323EDDD185_1920x1080.jpeg\",\"width\":1920,\"height\":1080},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/create-sql-server-stored-procedure-with-parameters\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"en\",\"item\":\"https:\/\/expert-only.com\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to create a SQL Server stored procedure with parameters ?\"}]},{\"@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 create a SQL Server stored procedure with parameters ?","description":"Tutorial with scripts to create and execute a SQL Server stored procedure with parameters and assign a default values to input variables.","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\/create-sql-server-stored-procedure-with-parameters\/","og_locale":"en_US","og_type":"article","og_title":"How to create a SQL Server stored procedure with parameters ?","og_description":"Tutorial with scripts to create and execute a SQL Server stored procedure with parameters and assign a default values to input variables.","og_url":"https:\/\/expert-only.com\/en\/t-sql\/create-sql-server-stored-procedure-with-parameters\/","og_site_name":"SQL and IT Tutorials","article_publisher":"https:\/\/www.facebook.com\/ExpertOnlyCom\/","article_published_time":"2023-11-16T06:41:00+00:00","article_modified_time":"2023-11-23T11:07:53+00:00","og_image":[{"width":1920,"height":1080,"url":"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/08\/inspiration_dark_new-york-city-F323EDDD185_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":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/expert-only.com\/en\/t-sql\/create-sql-server-stored-procedure-with-parameters\/#article","isPartOf":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/create-sql-server-stored-procedure-with-parameters\/"},"author":{"name":"Expert-Only","@id":"https:\/\/expert-only.com\/en\/#\/schema\/person\/406a9576b52944f018739a42046873ef"},"headline":"How to create a SQL Server stored procedure with parameters ?","datePublished":"2023-11-16T06:41:00+00:00","dateModified":"2023-11-23T11:07:53+00:00","mainEntityOfPage":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/create-sql-server-stored-procedure-with-parameters\/"},"wordCount":582,"commentCount":0,"publisher":{"@id":"https:\/\/expert-only.com\/en\/#organization"},"image":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/create-sql-server-stored-procedure-with-parameters\/#primaryimage"},"thumbnailUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/08\/inspiration_dark_new-york-city-F323EDDD185_1920x1080.jpeg","articleSection":["T-SQL"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/expert-only.com\/en\/t-sql\/create-sql-server-stored-procedure-with-parameters\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/expert-only.com\/en\/t-sql\/create-sql-server-stored-procedure-with-parameters\/","url":"https:\/\/expert-only.com\/en\/t-sql\/create-sql-server-stored-procedure-with-parameters\/","name":"How to create a SQL Server stored procedure with parameters ?","isPartOf":{"@id":"https:\/\/expert-only.com\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/create-sql-server-stored-procedure-with-parameters\/#primaryimage"},"image":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/create-sql-server-stored-procedure-with-parameters\/#primaryimage"},"thumbnailUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/08\/inspiration_dark_new-york-city-F323EDDD185_1920x1080.jpeg","datePublished":"2023-11-16T06:41:00+00:00","dateModified":"2023-11-23T11:07:53+00:00","description":"Tutorial with scripts to create and execute a SQL Server stored procedure with parameters and assign a default values to input variables.","breadcrumb":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/create-sql-server-stored-procedure-with-parameters\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/expert-only.com\/en\/t-sql\/create-sql-server-stored-procedure-with-parameters\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/expert-only.com\/en\/t-sql\/create-sql-server-stored-procedure-with-parameters\/#primaryimage","url":"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/08\/inspiration_dark_new-york-city-F323EDDD185_1920x1080.jpeg","contentUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/08\/inspiration_dark_new-york-city-F323EDDD185_1920x1080.jpeg","width":1920,"height":1080},{"@type":"BreadcrumbList","@id":"https:\/\/expert-only.com\/en\/t-sql\/create-sql-server-stored-procedure-with-parameters\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"en","item":"https:\/\/expert-only.com\/en\/"},{"@type":"ListItem","position":2,"name":"How to create a SQL Server stored procedure with parameters ?"}]},{"@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\/8833","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=8833"}],"version-history":[{"count":1,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/posts\/8833\/revisions"}],"predecessor-version":[{"id":29294,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/posts\/8833\/revisions\/29294"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/media\/5811"}],"wp:attachment":[{"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/media?parent=8833"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/categories?post=8833"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/tags?post=8833"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}