Results 1 to 3 of 3

Thread: update Trigger

  1. #1
    Join Date
    Oct 2003
    Location
    Buenos Aires, Argentina
    Posts
    20

    Question Unanswered: update Trigger

    hi folks.

    want to do this:
    /***************************************/
    CREATE TRIGGER TRGfechaModificacion
    ON UsuariosVencimientos
    AFTER UPDATE AS
    DECLARE @updatedID AS int
    BEGIN
    --Get the last ID updated
    SELECT @updatedID = @@updated --???
    -- Updated this record with the actual datetime
    UPDATE
    UsuariosVencimientos
    SET
    Fecha_Actualizacion = getDate()
    WHERE
    id = @updatedID
    END
    /***************************************/

    Resume:

    I want to get the 'id' updated so I can used for the update query

    thanx
    ------------------------------------
    Thanx
    ------------------------------------
    http://www.iespana.es/greatavatar/FIRMA/firma.jpg

  2. #2
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    You need to think in set based terms....

    Look at the inserted and deleted virual tables....

    UPDATE u
    SET Fecha_Actualizacion = getDate()
    FROM UsuariosVencimientos u
    INNER JOIN inserted i
    on u.id = i.id
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  3. #3
    Join Date
    Oct 2003
    Location
    Buenos Aires, Argentina
    Posts
    20
    Thanx a lot.

    I have never thought in "based terms" :P
    ------------------------------------
    Thanx
    ------------------------------------
    http://www.iespana.es/greatavatar/FIRMA/firma.jpg

Posting Permissions

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