Results 1 to 4 of 4

Thread: trigger

  1. #1
    Join Date
    Mar 2004
    Posts
    25

    Unanswered: trigger

    Hi I am totally new in MSSQL and I am trying to write a trigger.

    I am trying to log user's activity..

    Trigger should put user's name and time to appropriate fields of updated record when column let's say column_1 will be inserted or updated.


    any ideas how to write this ?

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Sure, check MSDN for a start.

    -PatP

  3. #3
    Join Date
    Nov 2003
    Location
    Romania
    Posts
    70
    Someting like this ......... only the last modification


    CREATE TRIGGER YourTriggerName ON YourTable
    FOR UPDATE , INSERT
    AS
    UPDATE YourTable
    SET [YourTable].[User_Name] =SUSER_SNAME(),
    [YourTable].[Data_Modificare] = GETDATE()
    FROM [YourTable]
    INNER JOIN Inserted ON [YourTable].[KeyField] = Inserted.[KeyFiled]

  4. #4
    Join Date
    Mar 2004
    Posts
    25

    thanx

    a lot

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •