1

I have a database which contains some tables such as article, news, projects,...

I want to save a record to another table (Activity) when a record inserted into each table in database without activity

I don't want to create a trigger for each table.

How can I do it?

2
  • 4
    Triggers are table-based - you cannot create "database-wide" triggers ... Commented Dec 14, 2014 at 19:30
  • do you have an idea for do this ? Commented Dec 14, 2014 at 19:32

1 Answer 1

1

If you were to use an intermediate layer, such as an ORM like Entity Framework, you could, in effect, have a "database wide" trigger, by overriding the OnSaveChanges event to add a log record anytime something is committed to the database.

My answer on This Question does exactly that

Sign up to request clarification or add additional context in comments.

2 Comments

Can I override OnSaveChanges Event?
Technically, you would want to override SaveChanges method of your implementation of ObjectContext. That is, if you are using entity framework.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.