USE StudentDB
GO
A prospective new student has come to our school. They want to enroll as a student, and then enroll into one course. You need to identify who they are as an individual, including any addresses and student information. Once they are enrolled as a student, you need to register them in a course.
Use two transactions, one for the student, and another for the course enrollment.
If the student cannot be added, do not attempt to enroll in the course.
Use a TRY/CATCH for each transaction to handle the errors and rollbacks.
Use SCOPE_IDENTITY() for non identity fields (FK's) in inserts.
Use a SQL script to execute the transactions, not a stored procedure.
Please run your code through the PoorSQL site, and uncheck the expand comma.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
27 | 28 | 29 | 30 | 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |