Question: Test the procedure by running the following execution statements , Exec spEmpTotals Exec spEmpTotals 'M% (This SP will return a total of all hours an
Test the procedure by running the following execution statements ,
Exec spEmpTotals
Exec spEmpTotals 'M%
(This SP will return a total of all hours an employee has worked during a given time period) Create a stored procedure named spEmpTotals that includes 3 input variables: @LastName (varchar(50)) @StartDate (smalldatetime) @EndDate (smalldatetime) Initially set LastName so that it defaults to returning every record if no value in input and set the 2 date variable to NULL. Next, test for null values in the date variables, if null is present, set both variables to the appropriate MIN or MAX value that exists in the PerFrom column of PayPeriod. Select the following columns: EmpName (concatenation of FirstName and LastName with a space between) TotWkHours (sum of WorkHours column) TotHolHours (sum of HolHours column) TotSickHours (sum of SickHours column) TotVacHours (sum of VacHours column) TotPersHours (sum of PersHours column) Filter the results where LastName is like the appropriate input variable and PerFrom column is valued between the two appropriate input variables. Group the query accordingly and sort the results by TotWkHours from largest to smallest
Step by Step Solution
There are 3 Steps involved in it
To create the stored procedure spEmpTotals and test it with the provided execution statements you ca... View full answer
Get step-by-step solutions from verified subject matter experts
