Reputation: 5962
I created a trigger for restricting the deletion of record from the database
in sql
server. This is my query for creating the trigger
create trigger del on details
for delete
as begin
rollback tran
end
This trigger restricts the user from deleting the record. But now, I want to create a trigger
which allows the user to delete the record one by one, not all at a time . How can I do this using a trigger
.
Upvotes: 1
Views: 150
Reputation: 4035
Try using (inside the trigger code):
SELECT COUNT(*) FROM Deleted
If larger than 1, rollback. You could also check if @@ROWCOUNT > 1
and then rollback if it is.
Upvotes: 2