Trigger to update data in another database

I have the following diagram:

Database: test. Table: per_login_user, Field: username (PK), password

Database: wavinet. Table: login_user, Field: username (PK), password

I want to create a trigger. Whenever a field passwordin a table per_login_userin the database is updated test, the same value will be copied to the field passwordin the table login_userin the databasewavinet

I have a google search and find this solution: http://forums.devshed.com/ms-sql-development-95/use-trigger-to-update-data-in-another-db-149985.html

But when I run this query:

CREATE TRIGGER trgPasswordUpdater ON dbo.per_login_user
FOR UPDATE
AS
UPDATE  wavinet.dbo.login_user
SET     password = I.password
FROM    inserted I
INNER JOIN
    deleted D
ON  I.username = D.username
WHERE   wavinet.dbo.login_wavinet.password = D.password

request return error message:

Msg 107, Level 16, State 3, Procedure trgPasswordUpdater, Line 4
The column prefix 'wavinet.dbo.login_wavinet' does not match with a table name or alias name used in the query.
+3
source share
1

login_user, FROM login_user. , . , UPDATE FROM, FROM:

UPDATE  wavinet.dbo.login_user 
SET     password = I.password 
FROM    wavinet.dbo.login_user
JOIN inserted I ON wavinet.dbo.login_wavinet.username = I.username

, JOIN - DELETED, WHERE. , , , A B , A , B...

: .

+3

Source: https://habr.com/ru/post/1746113/


All Articles