July 31, 2008 at 3:14 pm
We have an very critical application written in .net, since it's badly written, the users can delete the data from the application. For example, if there are orders in the web page the users can go into the application and delete the orders. I am not a .net programmer, so I am trying to see if I can do the following on the database side:
1. Create a ondelete trigger so that as soon as someone deletes the order, it should get into a deletedorders table along with the user who deleted the order.
And also if it can alert me as soon as a order is deleted that will be great too.
Thanks for your responses!!
July 31, 2008 at 3:24 pm
Sure you can create an on delete trigger that will log the delete. You may not be able to get the actual user name though, it all depends on how the application is connecting to the database. You use SUSER_NAME() to get the user name.
I would not recommend sending an email from within the trigger though, especially in SQL 7, 2000 because something could go wrong and cause the whole transaction to rollback. If you want to be notified about deletes set up a job that reads the log table, I assume you have a log_date, and schedule to run every N minutes sending you all the deletes that happened in the N + 10 minutes.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
August 1, 2008 at 7:14 am
Thanks for your response, actually we have a user's table in the database, whenever a new user wants to get access to that web application that user will be added to that table.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply