Home / Expert Answers / Computer Science / write-a-stored-procedure-that-inserts-a-new-record-to-the-humanresources-employeepayhistory-table-t-pa770

(Solved): Write a stored procedure that inserts a new record to the HumanResources.EmployeePayHistory table. T ...



Write a stored procedure that inserts a new record to the HumanResources.EmployeePayHistory table. The procedure should accept parameters for the BusinessEntityID, RateChangeDate, Rate, and PayFrequency fields.

a. The PayFrequency field should default to a value of 2 if no value is passed in the parameter.

b. The RateChangeDate field should default to today’s date if no value is passed in the parameter. (HINT: you cannot assign the GETDATE() function directly to the parameter declaration. This needs to be done in the body of the procedure.)

c. If the BusinessEntityD that is passed in the parameter does not exist in the HumanResources.Employee table, the procedure should output an error message on the screen and the procedure should stop running. d. If the PayFrequency field does not contain either a 1 or 2 as a value, the procedure should output an error message to the user and stop running.



We have an Answer from Expert

View Expert Answer

Expert Answer


Answer CREATE PROCEDURE insertEmployeePayHistory @BusinessEntityID int, @RateChangeDate date, @Rate money, @PayFrequency int = 2 AS BEGIN SET NOCOUNT ON; INSERT IGNORE INTO Huma
We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe