T-SQL-8-4 Iplement a trigger on the employee table that prevents the employee st
ID: 3924571 • Letter: T
Question
T-SQL-8-4
Iplement a trigger on the employee table that prevents the employee start date from being after the current date.
DATABASE (key fields are underlined)
EMPLOYEE TABLE: EMP_ID, EMP_LNAME, EMP_STREET, EMP_CITY, EMP_STATE, EMP_ZIP, EMP_START_DATE
TABLES TABLE: TABLE_ID, AREA_ID, TABLE_SEATS
AREA TABLE: AREA_ID, AREA_NAME, AREA_SUPERVISOR_EMPLOYEE_ID
CUSTOMER TABLE: CUST_ID, CUST_LAST_NAME, CUST_NUMBER_OF_GUESTS
ASSIGNMENT TABLE: EMP_ID, TABLE_ID
SEATING TABLE: CUST_ID, TABLE_ID, SEATING_COST, SEATING_DATE, SEATING_TIP
Explanation / Answer
create trigger checkDate
on EMPLOYEE
after update,insert
as
if exists(
select * from employee where emp_start_date >= currdate()
)
begin
RAISERROR( 'start date should be greater than current date.');
ROLLBACK TRANSACTION;
RETURN
end;
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.