Skip to content

Instantly share code, notes, and snippets.

@rustymyers
Created December 4, 2012 19:20
Show Gist options
  • Save rustymyers/4207703 to your computer and use it in GitHub Desktop.
Save rustymyers/4207703 to your computer and use it in GitHub Desktop.
CREATE TRIGGER movie_rental_insert On customer_rentals
FOR INSERT
AS BEGIN
UPDATE movies
SET num_rentals = num_rentals + 1
WHERE INSERTED.movie_id = movies.movie_id
END;
@rustymyers
Copy link
Author

CREATE TRIGGER movie_rental_insert On customer_rentals
FOR INSERT
AS BEGIN
UPDATE movies
SET num_rentals = num_rentals + 1
WHERE customer_rentals.movie_id = movies.movie_id
END;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment