From the course: Microsoft SQL Server 2016 Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Parameterized stored procedures

Parameterized stored procedures - SQL Server Tutorial

From the course: Microsoft SQL Server 2016 Essential Training

Start my 1-month free trial

Parameterized stored procedures

- [Instructor] Just like many other programming languages, the stored procedures in Microsoft SQL Server can accept values passed to them when we call the stored procedure. Passing these values is called parameters. So in this section, we're going to expand on the stored procedure we wrote previously. Rather that just look for high temperatures, we're instead going to look for high temperatures between two dates. Between a start date and an end date, and both of those dates will be passed to the stored procedure as parameters. I've staged some code for you in your exercise files. You take all of that and copy it into a new query window. And let's talk a little bit about it before we run it. So, we're creating a procedure called highTemperatureBetweenDates, and it's going to accept two parameters: one called startDate and one called endDate. With stored procedures, the parameters are always preceded by the @ sign, and we have to define a data type for them. I'll use datetime for both…

Contents