Question: 1 . Write a script that creates and calls a stored procedure named spInsertDepartment. First, code a statement that creates a procedure that adds a
Write a script that creates and calls a stored procedure named spInsertDepartment. First, code a statement that creates a procedure that adds a new row to the Departments table. To do that, this procedure should have one parameter for the department name.
Code at least two EXEC statements that test this procedure. Note that this table doesn't allow duplicate department names.
Write a script that creates and calls a function named fuStudentUnits that calculates the total course units of a student in the StudentCourses table. To do that, this function should accept one parameter for the student ID and it should return the sum of the course units for the student.
The SELECT statement that calls the function should return the StudentID from the StudentCourses table, the CourseNumber and CourseUnits from the Courses table, and the value return by the fnStudentUnits function for that student.
Write a script that creates and calls a function named faTuition that calculates the total tuition for a student. To do that, this function should accept one parameter for the student ID it should use the faStudentUnits function that you created in exercise and it should return the value of the tuition for that student depending on whether the student is fulltime more than nine units or parttime nine or fewer unitsHint: Use a cross join to work with data in the Students and Tuition tables.
The SELECT statement that calls the function should return the StudentID from the Students table, the value returned by the fuStudentUnits function for that student, and the value returned by the fnTuition function for that student. Return only rows for students taking one or more units.
Write a script that creates and calls a stored procedure named spInsertInstructor that inserts a row into the Instructors table. This stored procedure should accept one parameter for each of these columns: LastName, FirstName, Status, DepartmentChairman, AnnualSalary, and DepartmentID
This stored procedure should set the DateAdded column to the current date.
If the value for the AnnualSalary column is a negative number, the stored procedure should raise an error that indicates that this column doesn't accept negative numbers.
Code at least two EXEC statements that test this procedure.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
