From the course: SQL Server Machine Learning Services: Python

Unlock the full course today

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

Create a Python stored procedure

Create a Python stored procedure

From the course: SQL Server Machine Learning Services: Python

Start my 1-month free trial

Create a Python stored procedure

- [Male Instructor] Once you've written a Python Script that you're happy with, it's fairly simply to save the script as a stored procedure on the database server. This is particularly useful for scripts that you'd like to run over and over again or scripts that you'd like to give other database users access to without them having to know how to write and execute Python code. I've gone ahead and written a little script that generates 10 random numbers. Let's walk through it really quickly. First, I need to make use of the random module, which isn't available by default. So the first line here simply loads the module into memory so that I can use its functions. Next, I set up a variable called MyNumbers and assign it an empty list container. After that, the script starts a foreloop that will run through the following line 10 times. The loop will take the MyNumber list and append a random integer between one and a 101. Remember that these are not inclusive so the values that are added…

Contents