{"id":8722,"date":"2018-05-11T07:00:24","date_gmt":"2018-05-11T07:00:24","guid":{"rendered":"https:\/\/assignment.essayshark.com\/blog\/?p=8722"},"modified":"2023-01-02T09:21:44","modified_gmt":"2023-01-02T09:21:44","slug":"how-to-create-a-stored-procedure-in-sql-language","status":"publish","type":"post","link":"https:\/\/assignmentshark.com\/blog\/how-to-create-a-stored-procedure-in-sql-language\/","title":{"rendered":"How to Create a Stored Procedure in SQL Language"},"content":{"rendered":"<p><b>Creating and Using Stored Procedures in the SQL Language<\/b><\/p>\n<p><span style=\"font-weight: 400;\">In this guide, we will learn how to create and use the stored procedures in Transact-SQL and PL\/SQL languages.<\/span><\/p>\n<p><b>A call to a stored procedure that returns a parameter<\/b><\/p>\n<p><span style=\"font-weight: 400;\">We call a system stored procedure that returns a set of characteristics of the database and returns code for the database subject field. The results of the procedure are included in the report:<\/span><!--more--><\/p>\n<p>[code language=&#8221;sql&#8221;]<br \/>\nDECLARE @return INT<br \/>\nEXECUTE @return = sp_helpdb &#8216;CD&#8217;<br \/>\nPRINT &#8216;The sp returned: &#8216; + CONVERT(CHAR(10), @return)<br \/>\n[\/code]<\/p>\n<p><a href=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/create_stored_proced_1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-8734 size-large\" src=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/create_stored_proced_1-1024x299.png\" alt=\"\" width=\"604\" height=\"176\" srcset=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/create_stored_proced_1-1024x299.png 1024w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/create_stored_proced_1-300x88.png 300w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/create_stored_proced_1-768x224.png 768w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/create_stored_proced_1.png 1600w\" sizes=\"auto, (max-width: 604px) 100vw, 604px\" \/><\/a><\/p>\n<p><b>Maintenance of the database by using stored procedures<\/b><\/p>\n<ul>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Check the database subject area for physical errors using the DBCC utility (DBCC CHECKDB).<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Compress the database, and free up unused blocks by using the system utilities DBCC (DBCC SHRINKDATABASE).<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Update statistics (DB indexes) for all user tables to speed up data selection from the database using the stored procedure sp_updatestats.<\/span><\/li>\n<\/ul>\n<p>[code language=&#8221;sql&#8221;]<br \/>\nDBCC CHECKDB (&#8216;CD&#8217;, REPAIR_REBUILD)<br \/>\n[\/code]<\/p>\n<p><a href=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/create_stored_proced_2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-8732 size-large\" src=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/create_stored_proced_2-1024x351.png\" alt=\"\" width=\"604\" height=\"207\" srcset=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/create_stored_proced_2-1024x351.png 1024w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/create_stored_proced_2-300x103.png 300w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/create_stored_proced_2-768x263.png 768w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/create_stored_proced_2.png 1600w\" sizes=\"auto, (max-width: 604px) 100vw, 604px\" \/><\/a><\/p>\n<p>[code language=&#8221;sql&#8221;]<br \/>\nDBCC SHRINKDATABASE(&#8216;CD&#8217;, 10)<br \/>\n[\/code]<\/p>\n<p><a href=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/create_stored_proced_3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-8730 size-large\" src=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/create_stored_proced_3-1024x307.png\" alt=\"\" width=\"604\" height=\"181\" srcset=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/create_stored_proced_3-1024x307.png 1024w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/create_stored_proced_3-300x90.png 300w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/create_stored_proced_3-768x230.png 768w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/create_stored_proced_3.png 1600w\" sizes=\"auto, (max-width: 604px) 100vw, 604px\" \/><\/a><\/p>\n<p>[code language=&#8221;sql&#8221;]<br \/>\nEXEC sp_updatestats<br \/>\n[\/code]<\/p>\n<p><a href=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/create_stored_proced_4.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-8728 size-large\" src=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/create_stored_proced_4-1024x335.png\" alt=\"\" width=\"604\" height=\"198\" srcset=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/create_stored_proced_4-1024x335.png 1024w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/create_stored_proced_4-300x98.png 300w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/create_stored_proced_4-768x252.png 768w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/create_stored_proced_4.png 1600w\" sizes=\"auto, (max-width: 604px) 100vw, 604px\" \/><\/a><\/p>\n<p><b>Creation of the custom stored procedure<\/b><\/p>\n<ul>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Translate all the names of the dictionary in uppercase using the stored procedure.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">In both options include the contents of the table, sequence of operations, and the ultimate meaning of the table in the original report.<\/span><\/li>\n<\/ul>\n<p>[code language=&#8221;sql&#8221;]<br \/>\nIF EXISTS (SELECT name FROM sysobjects<br \/>\n\t\t   WHERE name = &#8216;CD&#8217; AND type = &#8216;P&#8217;)<br \/>\n\tDROP PROCEDURE CompUp<br \/>\nGO<\/p>\n<p>CREATE PROCEDURE CompUp<br \/>\nAS<br \/>\nUPDATE Clients SET Company = UPPER(Company)<\/p>\n<p>EXEC CompUp<br \/>\n[\/code]<\/p>\n<p><a href=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/create_stored_proced_5.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-8726 \" src=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/create_stored_proced_5-300x173.png\" alt=\"\" width=\"215\" height=\"124\" srcset=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/create_stored_proced_5-300x173.png 300w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/create_stored_proced_5-768x443.png 768w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/create_stored_proced_5-1024x591.png 1024w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/create_stored_proced_5.png 1316w\" sizes=\"auto, (max-width: 215px) 100vw, 215px\" \/><\/a><\/p>\n<p><strong>Creation of the custom stored procedures for analyzing database structure<\/strong><\/p>\n<p>Create a stored procedure that prints the lists of the user tables, views, SQL DML triggers and CHECK-constraints, and returns the total number of displayed objects through the parameter using SELECT.<\/p>\n<p>[code language=&#8221;sql&#8221;]<br \/>\nCREATE PROCEDURE Procedure1<br \/>\nAS<br \/>\nBEGIN<br \/>\n\tSELECT COUNT(type) AS Number, type AS TType FROM sysobjects<br \/>\n\tWHERE (type = &#8216;V&#8217; OR type = &#8216;U&#8217; OR type = &#8216;TR&#8217; OR type = &#8216;C&#8217;)<br \/>\n\tGROUP BY type<br \/>\nEND<br \/>\n[\/code]<\/p>\n<p><a href=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/create_stored_proced_6.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-8724 \" src=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/create_stored_proced_6-300x154.png\" alt=\"\" width=\"237\" height=\"122\" srcset=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/create_stored_proced_6-300x154.png 300w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/create_stored_proced_6-768x395.png 768w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/create_stored_proced_6-1024x527.png 1024w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2018\/03\/create_stored_proced_6.png 1394w\" sizes=\"auto, (max-width: 237px) 100vw, 237px\" \/><\/a><\/p>\n<h2>SQL Homework Assistance from AssignmentShark Experts<\/h2>\n<blockquote><p><em>As you have already noticed, this guide was written by an expert in IT. It shows how to create a stored procedure in SQL. You can have your assignments done properly if you order them from AssignmentShark.com. Since the range of our experts is vast, it is necessary to select a particular expert for your <a href=\"https:\/\/assignmentshark.com\/sql-homework-help.html\" target=\"_blank\" rel=\"noopener\">SQL homework<\/a>. Thus, different experts who work on our team are knowledgeable in different spheres of study. Consider the opportunity to use our service if you want to forget about your homework problems.<\/em><\/p><\/blockquote>\n<blockquote><p><em>We are available 24\/7. After you place an order on our site, our expert will start to work on it immediately. You can contact him or her directly via chat and ask any questions about the order that bother you. Also, you can request free revisions if you don&#8217;t like something in the completed order. You can be confident that you will get an assignment that is absolutely correct. What are you waiting for? Get <a href=\"https:\/\/assignmentshark.com\/\" target=\"_blank\" rel=\"noopener\">online assignment help<\/a> and we will assist you right now!<\/em><\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Creating and Using Stored Procedures in the SQL Language In this guide, we will learn how to create and use the stored procedures in Transact-SQL and PL\/SQL languages. A call to a stored procedure that returns a parameter We call a system stored procedure that returns a set of characteristics of the database and returns [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[53,35],"tags":[],"class_list":["post-8722","post","type-post","status-publish","format-standard","hentry","category-it","category-samples"],"_links":{"self":[{"href":"https:\/\/assignmentshark.com\/blog\/wp-json\/wp\/v2\/posts\/8722","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/assignmentshark.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/assignmentshark.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/assignmentshark.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/assignmentshark.com\/blog\/wp-json\/wp\/v2\/comments?post=8722"}],"version-history":[{"count":14,"href":"https:\/\/assignmentshark.com\/blog\/wp-json\/wp\/v2\/posts\/8722\/revisions"}],"predecessor-version":[{"id":13155,"href":"https:\/\/assignmentshark.com\/blog\/wp-json\/wp\/v2\/posts\/8722\/revisions\/13155"}],"wp:attachment":[{"href":"https:\/\/assignmentshark.com\/blog\/wp-json\/wp\/v2\/media?parent=8722"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/assignmentshark.com\/blog\/wp-json\/wp\/v2\/categories?post=8722"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/assignmentshark.com\/blog\/wp-json\/wp\/v2\/tags?post=8722"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}