Trigger to update data in another DB
Posted
by Permana
on Stack Overflow
See other posts from Stack Overflow
or by Permana
Published on 2010-05-19T02:26:57Z
Indexed on
2010/05/19
2:30 UTC
Read the original article
Hit count: 274
sql-server
|triggers
I have the following schema:
Database: test. Table: per_login_user, Field: username (PK), password
Database: wavinet. Table: login_user, Field: username (PK), password
What I want to do is to create a trigger. Whenever a password
field on table per_login_user
in database test
get updated, the same value will be copied to field password
in Table login_wavinet
in database wavinet
I have search trough Google 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
the query 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.
© Stack Overflow or respective owner