Learn your way! Get started

SQL 2014 Developer, Part 02 of 13: Stored Procedures

with expert Don Kiely


Watch trailer


Course at a glance

Included in these subscriptions:

  • Dev & IT Pro Video
  • Dev & IT Pro Power Pack

Release date 5/19/2015
Level Intermediate
Runtime 1h 46m
Closed captioning Included
Transcript Included
eBooks / courseware Included
Hands-on labs Included
Sample code Included
Exams Included


Enterprise Solutions

Need reporting, custom learning tracks, or SCORM? Learn More



Course description

In this course we’ll start by looking at stored procedure features and the benefits of using them. Then you’ll learn about the syntax of the CREATE PROCEDURE statement, and some of the options for using stored procedures, including input and output parameters, return values, and results sets. You’ll also learn how to debug these code modules, as well as shape the results when executing a stored procedure. Then you’ll learn about a special kind of stored procedure, a trigger. A trigger runs automatically in response to changes to your data, letting you enforce complex business rules and perform other actions. You’ll learn about the different kinds of triggers as well as some risks in their use, and then we’ll get into the details of creating and using triggers effectively.

Prerequisites

This course assumes that you have a basic familiarity with the concept of relational databases and a basic understanding of what SQL Server is and the high-level tools in it, as well as how to create and manage objects using Management Studio. You should also have a basic understanding of how SQL Server implements security, including its authentication and authorization schemes, and how to assign permissions on securable objects to principals. You should know the fundamentals of Transact-SQL to write queries to retrieve and update data, and how to execute scripts using the query editor in Management Studio. It will be very helpful, but not absolutely necessary, to have experience with .NET development using Visual Studio 2010 or 2012 for the portions of the course that deal with SQLCLR development. The .NET code included in this course is written in C#, but if you prefer Visual Basic it should be fairly easy to convert the code.

Learning Paths

This course will help you prepare for the following certifications and exams:
MCSE: Business Intelligence
MCSA: SQL Server 2012/2014
MCSE: Data Platform
70-464: Developing Microsoft SQL Server 2012/2014 Databases
70-461: Querying Microsoft SQL Server 2012/2014

This course is part of the following LearnNowOnline SuccessPaths™:
SQL Server Developer

Meet the expert

Don Kiely is a featured instructor on many of our SQL Server and Visual Studio courses. He is a nationally recognized author, instructor, and consultant specializing in Microsoft technologies. Don has many years of teaching experience, is the author or co-author of several programming books, and has spoken at many industry conferences and user groups. In addition, Don is a consultant for a variety of companies that develop distributed applications for public and private organizations.

Course outline



Stored Procedures

Introduction Stored Procedures (18:26)
  • Introduction (00:44)
  • Stored Procedure Features (03:28)
  • Performance Benefits (01:57)
  • Deferred Name Resolution (01:25)
  • Execution Plans (02:05)
  • Plan Recompilation (02:21)
  • Using Schema Qualifiers (02:24)
  • Why Use Stored Procedures (03:20)
  • Summary (00:38)
Creating Stored Procedures (19:36)
  • Introduction (00:34)
  • Stored Procedure Syntax (02:21)
  • Create Using Management Studio (00:51)
  • Demo: Ways to Create (03:04)
  • Demo: Creating a Procedure (03:26)
  • Demo: Explaining SET NOCOUNT (03:38)
  • Demo: Working With Parameters (03:08)
  • Demo: Optional Parameters (02:04)
  • Summary (00:24)
Returning Data From (14:13)
  • Introduction (00:44)
  • Demo: Output Parameters (03:19)
  • Demo: Return Statement (02:02)
  • Demo: Returning as Result Set (01:43)
  • Demo: Using Variables (04:28)
  • Demo: Syntax Errors (01:35)
  • Summary (00:21)

Stored Procedures Continued

Testing and Debugging (16:37)
  • Introduction (01:03)
  • Demo: Stepping into Code (03:49)
  • Demo: Debugging Windows (03:44)
  • Demo: Debug and Print Statment (02:46)
  • Demo: Variables with Procedures (02:55)
  • Demo: Test with Valid Inputs (01:17)
  • Demo: Test with Invalid Inputs (00:37)
  • Summary (00:23)
Execute with Result Sets (10:58)
  • Introduction (00:54)
  • Execute WITH RESULT SETS (02:13)
  • Demo: Execute WITH RESULT SETS (04:09)
  • Demo: Shaping Results (03:04)
  • Summary (00:36)
Creating Triggers (26:35)
  • Introduction (00:38)
  • Creating Triggers (01:08)
  • Types of Triggers (01:58)
  • Uses for Triggers (01:22)
  • The Trouble with Triggers (02:33)
  • How Triggers Work (01:56)
  • Demo: Creating Triggers (04:42)
  • Creating an INSTEAD OF Trigger (01:46)
  • Demo: Creating the View (01:07)
  • Demo: INSTEAD OF Trigger (04:52)
  • DDL Triggers (01:54)
  • Demo: DDL Triggers (02:01)
  • Summary (00:32)