Created
December 4, 2013 14:24
-
-
Save joeriks/7788225 to your computer and use it in GitHub Desktop.
sql trigger - revert value if condition is met
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ALTER TRIGGER reset_deleted | |
| ON mytable | |
| AFTER update | |
| AS | |
| IF (SELECT count(*) FROM inserted WHERE [type]='sometype' AND [deleted]=1)>0 | |
| BEGIN | |
| SET NOCOUNT ON; | |
| UPDATE mytable SET [deleted]=0 WHERE id in (SELECT id FROM inserted WHERE [type]='sometype' AND [deleted]=1) | |
| END | |
| GO |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment