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.
Get Free Quote!
442 Experts Online