From the course: Complete Guide to Advanced SQL Server
Unlock the full course today
Join today to access over 24,400 courses taught by industry experts.
Create a Python stored procedure - SQL Server Tutorial
From the course: Complete Guide to Advanced SQL Server
Create a Python stored procedure
Once you've written a Python script that you're happy with, it's fairly simple 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 for loop that'll run through the following line 10 times. The loop will take the MyNumber list and append a random integer between 1 and 101. Remember that these are not inclusive, so the values that are added to the list will be…
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.
Download courses and learn on the go
Watch courses on your mobile device without an internet connection. Download courses using your iOS or Android LinkedIn Learning app.
Contents
-
-
Write and execute a stored procedure7m 43s
-
(Locked)
Stored procedure input parameters7m 38s
-
(Locked)
Stored procedure output parameters3m 38s
-
(Locked)
Create a database trigger3m 37s
-
(Locked)
Challenge: Use function in a stored procedure1m 25s
-
(Locked)
Solution: Use function in a stored procedure7m 43s
-
-
-
(Locked)
What is error handling?1m 52s
-
(Locked)
Capture errors with TRY and CATCH4m 54s
-
(Locked)
Generate errors with THROW4m 12s
-
(Locked)
Manage transaction control4m 4s
-
(Locked)
Challenge: Add error handling to a stored procedure1m 12s
-
(Locked)
Solution: Add error handling to a stored procedure12m 12s
-
(Locked)
-
-
Automate SQL Server with triggers1m 48s
-
(Locked)
What are SQL Server triggers?3m 37s
-
(Locked)
Two triggers types: INSTEAD OF and AFTER2m 34s
-
(Locked)
Create a trigger to print a message6m 17s
-
Timestamp a table modification5m 31s
-
(Locked)
Firing INSTEAD OF triggers3m 23s
-
(Locked)
Challenge: Create a trigger58s
-
(Locked)
Solution: Create a trigger7m 10s
-
-
-
(Locked)
The Anaconda open-source packages7m 27s
-
(Locked)
Functions in the revoscalepy package1m 48s
-
(Locked)
Model, train, and score with microsoftml1m 16s
-
(Locked)
Produce graphics with Matplotlib7m 53s
-
(Locked)
Get descriptive statistics with pandas7m 45s
-
(Locked)
Challenge: Sample a DataFrame1m 12s
-
(Locked)
Solution: Sample a DataFrame5m 21s
-
(Locked)
-
-
(Locked)
Return values with indexes and series6m 8s
-
(Locked)
Convert a series to a DataFrame4m 40s
-
(Locked)
Add multiple series to a DataFrame3m 12s
-
(Locked)
Include the index in a DataFrame4m 44s
-
(Locked)
Slice a DataFrame to series4m 23s
-
(Locked)
Challenge: Import and process data52s
-
(Locked)
Solution: Import and process data6m 44s
-
(Locked)
-
-
GameScore database final project setup2m 38s
-
(Locked)
Create a trigger to add points to player records6m 30s
-
(Locked)
Calculate global score with custom function4m 7s
-
(Locked)
Write a stored procedure: Part 16m 19s
-
(Locked)
Write a stored procedure: Part 24m 44s
-
(Locked)
Add error handling and test the system: Part 16m 14s
-
(Locked)
Add error handling and test the system: Part 25m 52s
-