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.
Challenge: Create a transaction - SQL Server Tutorial
From the course: Complete Guide to Advanced SQL Server
Challenge: Create a transaction
For the third challenge of this course, I'd like to pull from what we've seen about creating stored procedures and combine it with some of our new knowledge about transactions. This will be a two-part challenge. We'll start building a solution now, and then finish it up at the end of the next chapter. So what is it that we want to do? In the 04_06_Challenge-Start.sql file is some code to build a BankAccounts table and then add a couple of rows of data. Your goal is to write a stored procedure that will allow you to easily transfer money from one account to the other. Your solution should include parameters that you can pass into the stored procedure, and then wrap the commands inside of a transaction so that the database will always be in a consistent state. Finally, test out your solution by transferring $50 from Account Number 1 to Account Number 3. This solution should take about 10 minutes or less to complete. In the next movie, I'll share my solution, and in the next chapter…
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.