From the course: Hands-On Advanced SQL Server: Strategies and Techniques
Unlock this course with a free trial
Join today to access over 25,300 courses taught by industry experts.
Stored procedure basics - SQL Server Tutorial
From the course: Hands-On Advanced SQL Server: Strategies and Techniques
Stored procedure basics
- If you've ever found yourself copying and pasting the same SQL query over and over, this lesson is going to change the game. We are introducing stored procedures, a way to save your queries and run them anytime with a single command. A stored procedure is like a shortcut. Instead of rewriting your logic every time, you write it once, save it, and reuse it whenever you need. No more repetition, just clean, reusable code. Now in this video, we're going to walk through everything from creating it to running it to updating, then deleting a stored prop. Okay, so let's begin with a common scenario. I'm working with a movie database, and every week, my manager's asking me for a report that shows total runtime and average runtime of all movies grouped by studio. Now, here's a SQL statement I would run in response to that. Now this query works great, but it's something I have to retype or paste every single time I need it. Now this is where a stored procedure can help. Before I go on, I'm…
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.