From the course: SQL Server Machine Learning Services: Python

Unlock the full course today

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

Parameterize the procedure

Parameterize the procedure

From the course: SQL Server Machine Learning Services: Python

Start my 1-month free trial

Parameterize the procedure

- [Narrator] There's an important additional benefit to turning your Python scripts into stored procedures. And it can be summed up in one word, customization. When your Python code incorporates parameters, you can easily modify the output of your script when it's saved as a stored procedure. Let's take another look at the same script that we used in the last movie. It currently generates 10 random numbers every time it's executed. But what if we'd like more control over how many numbers are returned in the result set? We can do that by passing in a variable to the script, when we run the stored procedure. To do this, let's turn the number 10 in the for loop to a new variable. I'll use the lowercase letter n for this, next, we'll go up here to the top and we'll add in a couple of empty lines. We'll start with the Create Procedure line at the top. We already have a stored procedure in the Wide World Importers database called random numbers. So I'm going to call this one Better Random…

Contents