SQL Stored Procedures - What They Are, Best Practices, Security, and More...

518,954
0
Published 2017-09-20
Newsletter signup (with exclusive discounts): signup.iamtimcorey.com/ (your email will be kept safe and you will not be spammed).
Facebook Page: www.facebook.com/IAmTimCorey/

Want to see a full C# application built from scratch?
Check out this course: iamtimcorey.com/courses/csharp-from-start-to-finis…

Microsoft SQL can be confusing. There are a TON of features, options, and settings to consider when attempting to use it. One of my favorite features is stored procedures. These pre-compiled queries allow you to safely and securely access and modify data. In this video, you will learn the basics of how to build a stored procedure, as well as what the benefits and drawbacks of stored procedures are. You will also learn some best practices, including how to secure your entire database in just a few simple commands.

Thanks to Ralfs HBK for timestamping the video:
0:00 - Intro
1:12 - Demo Data Base overview
2:00 - Creating new stored procedure
7:35 - Calling the stored procedure
10:11 - Changing existing stored procedure
11:12 - Stored procedure with variables
16:51 - Stored procedures: Recap
19:54 - Benefits of stored procedures: Security
22:57 - DB security: Users and Roles
32:49 - Other benefits of stored procedures
34:18 - Drawbacks: No source control
37:36 - Drawbacks: Business logic in DB
41:48 - Drawbacks: Using Entity Framework
43:26 - Summary and concluding remarks

All Comments (21)
  • @SmokeySpace
    Out of all the years of watching computer and programming tutorials, you teach things so much better and explain everything and explain it in a way that makes sense, thanks!
  • @cbuosi
    Im a professional, experienced developer and theres always something to learn from your videos, even with 'easy' topics such as this one. Thank you for your videos. Great work.
  • @bluemoon1357
    This is by far the best video i have ever seen on this topic, Thank you Tim
  • @shepniel
    Seriously this is the best channel about programming, at least for me, hope you continue with these videos that are really helpful. Thank you very much!
  • @giaptiennbros
    Hi Tim! You explain things and make it so simple, thank you !
  • Amazing video! Not only do you explain what stored procedures are, but you also give detailed background information and use cases. Keep up the great work!
  • @asyncawake9011
    Very easy to follow introduction to stored procedures. Just enough depth to get the general idea without getting bogged down in the details. Thank you for the great free content you provide!
  • @leozhang4574
    Hi Tim, I've watched a dozen of your videos and they are very useful. I'm also learning from you how to explain complex technical ideas in plain English to non-technical audience and even to junior programmers. Thank you! From Guangdong China.
  • @johnnyvcrow
    Thanks for pointing out that security matters! It's such a big deal today yet I still see so many tutorials where they completely disregard security matters.
  • @umitgulsen9869
    I was just preparing to move my classical ASP app ( including SP’s) to MVC with EF. Of course, I’m pleased with speed of execution of SP’s, especially in reports, but DB dependency is another consideration for me. I watched so many videos, even bought some trainings. Then I watched this video. It’s a perfect eye opener for me. I’ll watch your tutorial at first, then decide which way to go. Thank you this valuable information. Best regards.
  • @gr8one73
    This, and the rest of your videos the videos on this channel, is absolutely golden! The SQL course on your site is worth way more than you're charging. You and Derek Banas are The best source for this stuff. Thank you very much, Corey!!
  • @DevineAbyss
    This was one of the most understandable, cohesive, well structured and best introductions I have seen in my whole life. I came with no understanding of anything besides SQL-statements and programming (java etc.) and I feel, I have a decent idea of procedures and role-management now.
  • @juanminglao3699
    I've been watching your video's since the start of my programming journey 1 and a half years ago. Thank you for yet another great tutorial!
  • Fantastic video! Just had a recent interview for web dev in the financial sector and I have fairly little experience with T-SQL. One of the things they asked for me to do is additional research on Stored Procedures and this is the most clear and comprehensive guide I've seen thus far. I really appreciate it and I hope you're happy to hear how helpful you are for helping me get my next job!
  • @shader3020
    Thanks for the lesson. I enjoy that you teach more of the WHY and not just the HOW.
  • @donaldputout519
    Clear and efficient explanations. One of the best tutorial I saw till now on this subject. Thank's very much!
  • Thank you so very Much Tim. You have contributed so much to my career, truly i can't thank you enough, though i am yet having not much enough to subscribe to your paid programs and articles, i am looking forward to someday.
    This video is great, i often used Stored Procedures in my code but i found them to be time consuming and extra work to face so i began to do more of the unsecure query, query thing you know... but with this video, i think i will redirect my energy towards understanding it more and leverage on its benefits. Once again, Tim, Thank you a ton.
  • @gordonhope9219
    Tim, thanks for another great video!! Although I am now retired and never employed formally as an "engineer", much of my career was around managing a business that was highly secure and mission critical service network. Stored Procs are the way of life in such environments and, like you, NOBODY felt comfortable enough to executed the Entity Framework in such an environment. The business had to be able to fix ANYTHING that happened in the shortest time possible and performance was an issue. With about 1.5M connected end points sending in asynchronous signals, you can imagine how much data was coming into the network and why performance and security were so important. Kudos to you - you are correct about security!!
  • @adan-codes
    You are doing the lords work sir. Thank you, I needed this for a project at work.