{"id":18572,"date":"2023-08-03T06:38:00","date_gmt":"2023-08-03T04:38:00","guid":{"rendered":"https:\/\/expert-only.com\/?p=18572"},"modified":"2023-10-20T17:31:45","modified_gmt":"2023-10-20T15:31:45","slug":"insert-data-from-a-sql-server-procedure","status":"publish","type":"post","link":"https:\/\/expert-only.com\/en\/t-sql\/insert-data-from-a-sql-server-procedure\/","title":{"rendered":"How to insert data using a SQL Server stored procedure?"},"content":{"rendered":"\n<h4 class=\"wp-block-heading has-text-align-left\" id=\"h-how-to-use-t-sql-variables-to-insert-data-from-using-a-sql-server-stored-procedure\"><strong><em>How to use T-SQL variables to insert data from using a SQL Server stored procedure?<\/em><\/strong><\/h4>\n\n\n\n<p>Tutorial on how to insert data from a SQL Server stored procedure using T-SQL variables. And also how to show or hide the number of rows inserted by the procedure. This example of a T-SQL procedure inserts rows into a customer table. This is a 3 step tutorial to learn how to insert rows from a stored procedure with variables.<\/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\/insert-data-from-a-sql-server-procedure\/#1-create-the-sales-table-to-use-in-the-procedure\" >1. Create the sales table to use in the procedure<\/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\/insert-data-from-a-sql-server-procedure\/#2-create-the-sql-server-stored-procedure-to-insert-data\" >2. Create the SQL Server stored procedure to insert data<\/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\/insert-data-from-a-sql-server-procedure\/#3-option-to-hide-the-number-of-rows-inserted\" >3. Option to hide the number of rows inserted<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"1-create-the-sales-table-to-use-in-the-procedure\"><\/span>1. Create the sales table to use in the procedure<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>First, check that the example customers table does not exist. If the table exists, then delete it with the DROP TABLE command. Then create the customers table to insert the rows of the example.<\/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 table CUSTOMERS already exists\n-- And delete it if necessary\nIF EXISTS(\n   SELECT 1 FROM sys.objects\n   WHERE  object_id = object_id(N'[dbo].[CUSTOMERS]')\n      AND type in (N'U')\n)\nDROP TABLE [dbo].[CUSTOMERS]\nGO\n\n-- Create the CUSTOMERS table with the column NAME declared as UNIQUE\n-- The UNIQUE keyword defines the column with a unique value\n-- Inserting two customers with the same name is therefore impossible\nCREATE TABLE [dbo].[CUSTOMERS] (\n   [CLIENTID] int IDENTITY(1,1),\n   [NAME] nvarchar(20) UNIQUE,\n   [CITY] nvarchar(20)\n)\nGO\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"2-create-the-sql-server-stored-procedure-to-insert-data\"><\/span>2. Create the SQL Server stored procedure to insert data<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>First check if the stored <a href=\"https:\/\/www.pcmag.com\/encyclopedia\/term\/stored-procedure\" target=\"_blank\" rel=\"noreferrer noopener\">procedure<\/a> already exists in the database and delete it if necessary. Secondly, create the stored procedure uspInsertClient to insert two fields passed as parameters, the name and the city, into the customer table.<\/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=\"\">IF EXISTS( \n  SELECT 1 FROM sys.objects \n  WHERE object_id = object_id(N'uspInsertCustomer')\n  AND type in (N'P') )\nDROP PROCEDURE uspInsertCustomer;\nGO\n\nCREATE PROCEDURE dbo.uspInsertCustomer\n  @Name nvarchar(20),\n  @City nvarchar(20)\nAS\nBEGIN\n  INSERT INTO dbo.Customers (Name, City) \n  VALUES (@Name, @City);\nEND;\n\nGO\n<\/pre>\n\n\n\n<p>Run the procedure three times to insert new customers into the table.<\/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=\"\">-- Deactivate the option to hide the number of insertions\nSET NOCOUNT OFF;\n\n-- Insert three new customers\nEXECUTE dbo.uspInsertCustomer @Name = 'MAMMADOU', @City = 'Toulouse';\nEXECUTE dbo.uspInsertCustomer @Name = 'KARIM', @City = 'Nantes';\nEXECUTE dbo.uspInsertCustomer @Name = 'ISAAC', @City = 'Versailles';\n<\/pre>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"720\" height=\"440\" src=\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/11\/sql-server-insert-data-from-sql-server-stored-procedure.jpg\" alt=\"Insert data from a SQL Server stored procedure with SSMS\" class=\"wp-image-18579\" srcset=\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/11\/sql-server-insert-data-from-sql-server-stored-procedure.jpg 720w, https:\/\/expert-only.com\/wp-content\/uploads\/2022\/11\/sql-server-insert-data-from-sql-server-stored-procedure-300x183.jpg 300w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><figcaption class=\"wp-element-caption\"><em>Insert data from a SQL Server stored procedure with SSMS<\/em><\/figcaption><\/figure><\/div>\n\n\n<p>This example of an insert query in the SQL Server stored procedure is used to insert rows into a table. The code checks for the existence of the procedure beforehand to avoid errors on creation. The code makes it easy to call the created procedure with the parameters. And thus to standardise the insertion of data in this table.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"3-option-to-hide-the-number-of-rows-inserted\"><\/span>3. Option to hide the number of rows inserted<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>When you insert data from a SQL Server procedure, by default, the system displays the number of rows inserted. The SET NOCOUNT ON command tells SQL Server not to display the number of rows affected. In our case, inserted by the SQL INSERT query. Thus, if the option is enabled, the number of rows is not shown, as in the example below. This display option allows you to avoid polluting files or log tables during the execution of complex stored procedures.<\/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=\"\">-- Deactivate the option to hide the number of insertions\nSET NOCOUNT ON;\n\n-- Insert three clients with the option enabled\nEXECUTE dbo.uspInsertCustomer @Name = 'ISACH', @City = 'Lille';\nEXECUTE dbo.uspInsertCustomer @Name = 'AHMED', @City = 'Bordeaux';\nEXECUTE dbo.uspInsertCustomer @Name = 'YANIS', @City = 'Marseille';\n<\/pre>\n\n\n\n<p>Finally, check the result of the query and read the data with a SELECT query on the customer table. Note that the three clients are present twice each in the table. This corresponds to the six executions of the SQL command. That is, three times with the row count display option on and three times with the display option off.<\/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=\"\">SELECT *\nFROM dbo.Customers;\n<\/pre>\n\n\n\n<p>This T-SQL development tutorial explains how to insert data from a SQL Server stored procedure. Finally, here is a tutorial on <a href=\"https:\/\/expert-only.com\/en\/t-sql\/return-values-sql-server-stored-procedure\/\">how to create a SQL stored procedure that returns values<\/a> with the OUTPUT option.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Conclusion on data insertion using SQL Server stored procedures<\/h3>\n\n\n\n<p>This T-SQL tutorial explains how to create a sales table and a SQL Server stored procedure, and ultimately insert data using variables. The tutorial also teaches how to control the display of the number of rows inserted by using the SET NOCOUNT command. By following these steps, it is possible to effectively standardize data insertion and manage the display of row counts for more complex stored procedures.<\/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=\"17GzQnSd0e\"><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=iu1tzXK0bG#?secret=17GzQnSd0e\" data-secret=\"17GzQnSd0e\" 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>How to use T-SQL variables to insert data from using a SQL Server stored procedure? Tutorial on how to insert data from a SQL Server stored procedure using T-SQL variables. And also how to show or hide the number <a class=\"mh-excerpt-more\" href=\"https:\/\/expert-only.com\/en\/t-sql\/insert-data-from-a-sql-server-procedure\/\" title=\"How to insert data using a SQL Server stored procedure?\">&#8230;<\/a><\/p>\n<\/div>","protected":false},"author":1,"featured_media":10714,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[454],"tags":[],"class_list":{"0":"post-18572","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 insert data using a SQL Server stored procedure? T-SQL<\/title>\n<meta name=\"description\" content=\"Sample code to insert data from a SQL Server stored procedure using T-SQL variables and use an INSERT INTO statement in the instructions.\" \/>\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\/insert-data-from-a-sql-server-procedure\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to insert data using a SQL Server stored procedure?\" \/>\n<meta property=\"og:description\" content=\"Sample code to insert data from a SQL Server stored procedure using T-SQL variables and use an INSERT INTO statement in the instructions.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/expert-only.com\/en\/t-sql\/insert-data-from-a-sql-server-procedure\/\" \/>\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-08-03T04:38:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-10-20T15:31:45+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/keyboard-6578692B4E6_1920x1080.jpg\" \/>\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\/insert-data-from-a-sql-server-procedure\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/insert-data-from-a-sql-server-procedure\/\"},\"author\":{\"name\":\"Expert-Only\",\"@id\":\"https:\/\/expert-only.com\/en\/#\/schema\/person\/406a9576b52944f018739a42046873ef\"},\"headline\":\"How to insert data using a SQL Server stored procedure?\",\"datePublished\":\"2023-08-03T04:38:00+00:00\",\"dateModified\":\"2023-10-20T15:31:45+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/insert-data-from-a-sql-server-procedure\/\"},\"wordCount\":521,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/expert-only.com\/en\/#organization\"},\"image\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/insert-data-from-a-sql-server-procedure\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/keyboard-6578692B4E6_1920x1080.jpg\",\"articleSection\":[\"T-SQL\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/expert-only.com\/en\/t-sql\/insert-data-from-a-sql-server-procedure\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/insert-data-from-a-sql-server-procedure\/\",\"url\":\"https:\/\/expert-only.com\/en\/t-sql\/insert-data-from-a-sql-server-procedure\/\",\"name\":\"How to insert data using a SQL Server stored procedure? T-SQL\",\"isPartOf\":{\"@id\":\"https:\/\/expert-only.com\/en\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/insert-data-from-a-sql-server-procedure\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/insert-data-from-a-sql-server-procedure\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/keyboard-6578692B4E6_1920x1080.jpg\",\"datePublished\":\"2023-08-03T04:38:00+00:00\",\"dateModified\":\"2023-10-20T15:31:45+00:00\",\"description\":\"Sample code to insert data from a SQL Server stored procedure using T-SQL variables and use an INSERT INTO statement in the instructions.\",\"breadcrumb\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/insert-data-from-a-sql-server-procedure\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/expert-only.com\/en\/t-sql\/insert-data-from-a-sql-server-procedure\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/insert-data-from-a-sql-server-procedure\/#primaryimage\",\"url\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/keyboard-6578692B4E6_1920x1080.jpg\",\"contentUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/keyboard-6578692B4E6_1920x1080.jpg\",\"width\":1920,\"height\":1080},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/insert-data-from-a-sql-server-procedure\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"en\",\"item\":\"https:\/\/expert-only.com\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to insert data using a SQL Server stored procedure?\"}]},{\"@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 insert data using a SQL Server stored procedure? T-SQL","description":"Sample code to insert data from a SQL Server stored procedure using T-SQL variables and use an INSERT INTO statement in the instructions.","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\/insert-data-from-a-sql-server-procedure\/","og_locale":"en_US","og_type":"article","og_title":"How to insert data using a SQL Server stored procedure?","og_description":"Sample code to insert data from a SQL Server stored procedure using T-SQL variables and use an INSERT INTO statement in the instructions.","og_url":"https:\/\/expert-only.com\/en\/t-sql\/insert-data-from-a-sql-server-procedure\/","og_site_name":"SQL and IT Tutorials","article_publisher":"https:\/\/www.facebook.com\/ExpertOnlyCom\/","article_published_time":"2023-08-03T04:38:00+00:00","article_modified_time":"2023-10-20T15:31:45+00:00","og_image":[{"width":1920,"height":1080,"url":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/keyboard-6578692B4E6_1920x1080.jpg","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\/insert-data-from-a-sql-server-procedure\/#article","isPartOf":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/insert-data-from-a-sql-server-procedure\/"},"author":{"name":"Expert-Only","@id":"https:\/\/expert-only.com\/en\/#\/schema\/person\/406a9576b52944f018739a42046873ef"},"headline":"How to insert data using a SQL Server stored procedure?","datePublished":"2023-08-03T04:38:00+00:00","dateModified":"2023-10-20T15:31:45+00:00","mainEntityOfPage":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/insert-data-from-a-sql-server-procedure\/"},"wordCount":521,"commentCount":0,"publisher":{"@id":"https:\/\/expert-only.com\/en\/#organization"},"image":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/insert-data-from-a-sql-server-procedure\/#primaryimage"},"thumbnailUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/keyboard-6578692B4E6_1920x1080.jpg","articleSection":["T-SQL"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/expert-only.com\/en\/t-sql\/insert-data-from-a-sql-server-procedure\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/expert-only.com\/en\/t-sql\/insert-data-from-a-sql-server-procedure\/","url":"https:\/\/expert-only.com\/en\/t-sql\/insert-data-from-a-sql-server-procedure\/","name":"How to insert data using a SQL Server stored procedure? T-SQL","isPartOf":{"@id":"https:\/\/expert-only.com\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/insert-data-from-a-sql-server-procedure\/#primaryimage"},"image":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/insert-data-from-a-sql-server-procedure\/#primaryimage"},"thumbnailUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/keyboard-6578692B4E6_1920x1080.jpg","datePublished":"2023-08-03T04:38:00+00:00","dateModified":"2023-10-20T15:31:45+00:00","description":"Sample code to insert data from a SQL Server stored procedure using T-SQL variables and use an INSERT INTO statement in the instructions.","breadcrumb":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/insert-data-from-a-sql-server-procedure\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/expert-only.com\/en\/t-sql\/insert-data-from-a-sql-server-procedure\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/expert-only.com\/en\/t-sql\/insert-data-from-a-sql-server-procedure\/#primaryimage","url":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/keyboard-6578692B4E6_1920x1080.jpg","contentUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/keyboard-6578692B4E6_1920x1080.jpg","width":1920,"height":1080},{"@type":"BreadcrumbList","@id":"https:\/\/expert-only.com\/en\/t-sql\/insert-data-from-a-sql-server-procedure\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"en","item":"https:\/\/expert-only.com\/en\/"},{"@type":"ListItem","position":2,"name":"How to insert data using a SQL Server stored procedure?"}]},{"@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\/18572","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=18572"}],"version-history":[{"count":1,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/posts\/18572\/revisions"}],"predecessor-version":[{"id":27587,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/posts\/18572\/revisions\/27587"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/media\/10714"}],"wp:attachment":[{"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/media?parent=18572"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/categories?post=18572"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/tags?post=18572"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}