All pastes #432268 Raw Edit

reznor

public sql v1 · immutable
·published 2007-04-10 04:07 UTC
rendered paste body
-- 1.	An Insert/Update trigger on the Customer table to ensure that the RouteID is valid. -- Should an invalid RouteID be entered, raise an error and rollback the transaction. -- Disable the constraint(s) required to test this trigger. Show all the code required to do this.-- Question #1DROP TRIGGER Valid_Route_IDGOCREATE TRIGGER Valid_Route_IDON CustomerFOR INSERT, UPDATE AS	IF @@RowCount > 0 and UPDATE(RouteID)		BEGIN			IF NOT Exists(	SELECT RouteID					FROM   Route					WHERE  Route.RouteID = RouteID				     )				BEGIN					ROLLBACK TRANSACTION					RAISERROR('Route ID is not valid', 16, 1)				END			-- ENDIF		END	RETURN	GO