Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2003
    Location
    Recife - PE - Brazil
    Posts
    28

    Exclamation Unanswered: Help me Please to Create this TRIGGER

    Hi everybody,

    How can I Update a field from another table by Trigger? Can someone send me the statment to do it?

    I have a table called Clients with fields : ID_Clients, Client
    And Another called Doc with fields : ID_Doc, ID_Clients, Client

    These tables are in different databases and I would like to esure the integrity by add a Trigger to update in Doc´s table the field Client everytime it´s changed in the Client´s table.

    Thanks for Attetion.

    Leonardo Almeida

  2. #2
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    This is not a forum for tutorials.

    Here is some sample code:

    CREATE TRIGGER YourTrigger ON dbo.YourTable
    FOR UPDATE
    AS
    update DBName.DBTable
    set YourField = inserted.YourField
    from DBName.DBTable
    inner join inserted on DBName.DBTable.KeyField = inserted.KeyField

    Please read about triggers in Books Online and then post again if you have a specific question.

    blindman

Posting Permissions

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