Triggers

  • Hi everyone,

    I plan to use triggers to record the user name and date when a column in a table is updated. For exp. I have 3 columns: Question; Updated_By; Updated_At. When the Question is updated, I want to use a trigger to insert the name of the person doing UPDATE into Updated_By and insert the date into Updated_At. Is there another better way to meet what I want beside triggers? What is the CONS of using triggers like this?

  • From what you state it is best performed at the UPDATE itself in an SP or UPDATE statement. The only CON with a TRIGGER to do this is that it has to run an UPDATE on the table again and you need to make sure you don't cause a trigger to fire another trigger (which shouldn't be an issue unless set the server to allow this).

    "Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)

  • The silly thing is all programmers here prefer to use EM to update the table. So they will not use SP or UPDATE statement! The table is just for look up. It has roughly 100 records, rarely updated. The trigger I wanted to use will not fire another.

    Thx.

  • Tell those programmers to develop an app to execute your sp and. Are you handling security?

  • Here it is.

    We are ASP, IIS, and SQL. I am SA, all developers has read and write to all tables and views. There are lookup tables for rates. IIS look at the rates, ASP calculate and present the result to client in IE. All they want to do is being able to update the rates in EM. No one is interested in Query Analyzer! So my option is using trigger.

  • Just a small note, that adding a username field and date field to each table can really affect your row sizes. and thus performance.

    Simon Sabin

    Co-author of SQL Server 2000 XML Distilled

    http://www.amazon.co.uk/exec/obidos/ASIN/1904347088


    Simon Sabin
    SQL Server MVP

    http://sqlblogcasts.com/blogs/simons

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply