From the course: SQL Server 2014 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: SQL Server 2014 Essential Training

Start my 1-month free trial

Parameterized stored procedures

- In this section, I'd like to go a little farther with stored procedures, and talk about some more options and some more advanced techniques. Again I've staged some code for you, in your exercise files, you can copy and paste all of that code into a new query, and let's talk about it before we run it. Again, we have the key word "CREATE" and the key word "PROCEDURE," and this time I called it Sales Person By Sales, my goal here is to return a list of sales people, based on how much they have sold, so this stored procedure will accept one parameter, the parameter will be a number, and the query will only return sales people who have sold more than that number. We see on the second line how I'm passing the parameter, parameters in stored procedures always start with the "@" sign, and then you can name it whatever you want, so I called it Sales Value. Then you need to put the keyword "AS" and what data type you're interested in. So Sales Value AS i-n-t, which means integer. Then we put…

Contents