From the course: Microsoft SQL Server 2022 Essential Training
Unlock this course with a free trial
Join today to access over 24,100 courses taught by industry experts.
Parameterized stored procedures - SQL Server Tutorial
From the course: Microsoft SQL Server 2022 Essential Training
Parameterized stored procedures
- Stored procedures are a great way to simplify and consolidate the process of passing instructions to the database, but it's important to ensure that you're being efficient with their use. What you don't want is to create a thousand stored procedures that each address a single use case. Maintenance, and your sanity will be greatly improved by finding opportunities to create stored procedures that serve a variety of functions. One of the main ways of doing this is by utilizing parameters that alter the procedure's scope. These parameters can be specified by the end user when they run the procedure so that a single stored procedure can serve up results to a variety of situations or questions. Let's take a look at how this works by creating a new procedure in the Wide World Importers database, we'll put it inside of the warehouse schema, and I'll call it uspSelectProductsByColor. Then we'll add a parameter that will alter the…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
Create a view of the data8m 33s
-
(Locked)
Data table indexes3m 49s
-
(Locked)
Create additional indexes on a table2m 52s
-
(Locked)
Aggregate functions7m 14s
-
(Locked)
Use built-in functions5m 15s
-
(Locked)
Leverage user-defined scalar functions7m 12s
-
(Locked)
Introduction to stored procedures3m 58s
-
(Locked)
Create stored procedures5m 34s
-
(Locked)
Parameterized stored procedures4m 42s
-
-
-
-
-