-
Trigger for delete or specific update
I have a table where I want to prevent user from deleting or setting a flag on a field to "y" with a database trigger (sql 2000). I understand the trigger for just one (stopping the delete, or stopping the field being changed to "y"). Should I have 2 seperate triggers or would there be a way to handle both.
-
One trigger can work for both, you just need to put the trigger fire condition as
CREATE TRIGGER tg ON TABLE t1
FOR UPDATE, DELETE
AS
...
-
That I get, it was trying to separate the login. If you are doing just a straight delete the trigger would be
create trigger tg on table for delete.....
In this cas trying to figure out logic for delete first and then for update. What would be the way to determine if the record was deleted? I know in triggers the records are referenced from deleted.name, or inserted.name
-
If get value in deleted but not in inserted, it's delete. Otherwise, is update.
-
In short if @@rowcount from inserted = 0 then...........
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|