Create stored procedures and user-defined functions

Advanced
Data Analyst
Data Engineer
Data Scientist
Database Administrator
Developer
Solution Architect
Student
Azure SQL Database
Azure SQL Managed Instance
SQL Server on Azure Virtual Machines
Azure SQL Server on Virtual Machines
SQL Server

Learn how to use Stored procedures to group T-SQL statements so they can be used and reused whenever needed. You may need to execute stored procedures that someone else has created or create your own.

Learning objectives

After completing this module, you'll be able to:

  • Return results by executing stored procedures.

  • Pass parameters to procedures.

  • Create simple stored procedures that encapsulate a SELECT statement.

  • Construct and execute dynamic SQL with EXEC and sp_executesql.

  • Create simple user-defined functions and write queries against them.

Prerequisites

Before starting this module, you should have experience of using Transact-SQL queries to retrieve and filter data from a table in a database.