SQL Server Performance

Trigger for tables on different database

Discussion in 'General Developer Questions' started by fmenditto, Jun 25, 2004.

  1. fmenditto New Member

    I have different database all with a table PEOPLE. In this table there are two field: USER_ID and USER_PASSWORD. I want to write a trigger so when a user changes USER_PASSWORD field in one database I update the same field in other databases. The problem is that the name of databases to update are in another table REMOTE_LIBRARIES. The trigger look like this

    CREATE TRIGGER PWD_UPD ON PEOPLE
    FOR UPDATE
    AS

    UPDATE t1
    SET t1.USER_PASSWORD = i.USER_PASSWORD
    FROM a..PEOPLE t1
    INNER JOIN inserted i
    ON t1.USER_ID = i.USER_ID

    where a is the result of
    SELECT DATABASE_NAME FROM REMOTE_LIBRARIES a WHERE SYSTEM_ID <> 0

    How can I use the result of the SELECT in UPDATE query trigger?

    Thanks to all

Share This Page