Results 1 to 2 of 2

Thread: Trigger code

  1. #1
    Join Date
    Feb 2009
    Posts
    1

    Unanswered: Trigger code

    I need a update trigger in one schema so that it can keep monitoring database table of other schema , both schema in residing on same machine , is it possible in SQL server 2000 ?
    if yes than could some one help me with syntax to be used to create such update trigger
    for example if i have schema abc and pqr than i need trigger residing in abc and it keep monitoring lets say table customer_detail in pqr if any change done in customer_detail should reflect tables present in abc..

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Code:
    CREATE TRIGGER pqr.test_trigger
      ON pqr.customer_detail
      AFTER UPDATE
    AS
      BEGIN
        UPDATE abc.customer_detail
        SET    some_field = x.some_field
             , other_field = x.other_field
        FROM   abc.customer_detail As x
         INNER
          JOIN inserted As i
            ON i.common_field = x.common_field
      END
    GO
    George
    Home | Blog

Posting Permissions

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