Introduction SQL Server stored procedures are essential structures for supporting client/server and n-tier distributed applications. These are essentially application modules or programs that are saved inside a database server’s system tables. They can be invoked by other clients or application tiers and are generally processed on the same server platform that supports the database server. Stored procedures are database objects that are defined in the American National Standards Institute ANSI/92 standard as part of the Transact-SQL extension. Other objects defined in this extension include triggers, views, cursors, datatypes, and user-defined datatypes. Stored procedures support the SQL data definition language (DDL), SQL data manipulation language (DML), SQL data control language (DCL), and control-of-flow statements. The Basic Process
Stored procedures are created and saved under unique names within system tables in a database. The essential process for manipulating stored procedures is to first use a text editor or a wizard to write the code of the stored procedure. Then drop the stored procedure from a specific database if it already exits. Next, compile the stored procedure into the system tables of a specific database. Then fix any compile errors and recompile the stored procedure until it compiles successfully. Successful compiles store the procedure text into several system tables (including sysobjects and syscomments) and also builds a cost-based execution plan that is saved into the data dictionary. Finally, stored procedures are executed by name with an optional parameter list. Design Philosophy and n-tier architecture There is a great deal of flexibility in building the contents of stored procedures. Since they can contain a combination of DDL, DML, DCL and Transact-SQL statements, stored procedures can support the same functionality as modules written in third generation language.
Traditional client/server architecture provides a fair degree of freedom in stored procedure design that can range from simple (affecting a single table) to highly complex (including validation code and support for business processes). N-tier architecture specifically relies on an additional application layer that supports stateless objects. Stored procedures that are simplified and atomic are better suited to this type of architecture. At the physical level, this layer can be implemented using the Microsoft Transaction Server (MTS). Common atomic level stored procedures complete a single operation against a table, such as selecting data rows from a table or view (SELECT), inserting data rows into a table or view (INSERT), deleting data rows from a table or view (DELETE), and updating columns in a table or view (UPDATE). Benefits The essential benefits of stored procedures focus on application performance, security, encapsulation, and change management. Use of stored procedures in an application can dramatically improve performance. This can happen for several reasons. A reduced volume of data is sent across a network in terms of command statements and result sets. Stored procedures are precompiled, and can be executed faster than the alternative method of issuing dynamic SQL statements. Stored procedures are also commonly used to manage security. Permissions can be established for stored procedures to limit user access to the database. Since stored procedures are saved inside SQL Server, its code is maintained inside a corporate firewall. The logic is protected by all the security measures available to protect the platform server. Version Control of Stored Procedure Code
Stored procedures should be created using text script files. It is highly recommended to maintain script files after the stored procedures are successfully compiled into the database server. This is to ensure that previous versions of a stored procedure can be recreated in the future. The database server only retains the current successfully compiled version. The script files should be managed within a change management/version control process that is applied to other application code. SQL Server 7 supplies a ‘create stored procedures’ wizard that offers a quick way to build three basic types of stored procedures for table processing, including insert, delete, and update table operations. It is recommended to save text script files separately after the stored procedures are generated using this wizard. Now that you have the introduction of leveraging SQL Server 7.0 stored procedures be sure to check back next week as Sanjiv Purba explains how to create and execute stored procedures. About the author:Sanjiv Purba is a Senior Manager with Deloitte Consulting. He is the author of five books published by John Wiley, the most recent of which is Building Microsoft SQL Server 7 Applications with COM. |
Ethics and Artificial Intelligence: Driving Greater Equality
FEATURE | By James Maguire,
December 16, 2020
AI vs. Machine Learning vs. Deep Learning
FEATURE | By Cynthia Harvey,
December 11, 2020
Huawei’s AI Update: Things Are Moving Faster Than We Think
FEATURE | By Rob Enderle,
December 04, 2020
Keeping Machine Learning Algorithms Honest in the ‘Ethics-First’ Era
ARTIFICIAL INTELLIGENCE | By Guest Author,
November 18, 2020
Key Trends in Chatbots and RPA
FEATURE | By Guest Author,
November 10, 2020
FEATURE | By Samuel Greengard,
November 05, 2020
ARTIFICIAL INTELLIGENCE | By Guest Author,
November 02, 2020
How Intel’s Work With Autonomous Cars Could Redefine General Purpose AI
ARTIFICIAL INTELLIGENCE | By Rob Enderle,
October 29, 2020
Dell Technologies World: Weaving Together Human And Machine Interaction For AI And Robotics
ARTIFICIAL INTELLIGENCE | By Rob Enderle,
October 23, 2020
The Super Moderator, or How IBM Project Debater Could Save Social Media
FEATURE | By Rob Enderle,
October 16, 2020
FEATURE | By Cynthia Harvey,
October 07, 2020
ARTIFICIAL INTELLIGENCE | By Guest Author,
October 05, 2020
CIOs Discuss the Promise of AI and Data Science
FEATURE | By Guest Author,
September 25, 2020
Microsoft Is Building An AI Product That Could Predict The Future
FEATURE | By Rob Enderle,
September 25, 2020
Top 10 Machine Learning Companies 2021
FEATURE | By Cynthia Harvey,
September 22, 2020
NVIDIA and ARM: Massively Changing The AI Landscape
ARTIFICIAL INTELLIGENCE | By Rob Enderle,
September 18, 2020
Continuous Intelligence: Expert Discussion [Video and Podcast]
ARTIFICIAL INTELLIGENCE | By James Maguire,
September 14, 2020
Artificial Intelligence: Governance and Ethics [Video]
ARTIFICIAL INTELLIGENCE | By James Maguire,
September 13, 2020
IBM Watson At The US Open: Showcasing The Power Of A Mature Enterprise-Class AI
FEATURE | By Rob Enderle,
September 11, 2020
Artificial Intelligence: Perception vs. Reality
FEATURE | By James Maguire,
September 09, 2020
Datamation is the leading industry resource for B2B data professionals and technology buyers. Datamation's focus is on providing insight into the latest trends and innovation in AI, data security, big data, and more, along with in-depth product recommendations and comparisons. More than 1.7M users gain insight and guidance from Datamation every year.
Advertise with TechnologyAdvice on Datamation and our other data and technology-focused platforms.
Advertise with Us
Property of TechnologyAdvice.
© 2025 TechnologyAdvice. All Rights Reserved
Advertiser Disclosure: Some of the products that appear on this
site are from companies from which TechnologyAdvice receives
compensation. This compensation may impact how and where products
appear on this site including, for example, the order in which
they appear. TechnologyAdvice does not include all companies
or all types of products available in the marketplace.