This should be so simple, but I can't seem to get it!
I have two databases that are identical (Demodata and Data_01). When a user inserts or deletes a record in a specific table in Demodata, I want to make the same thing happen to the same table in Data_01.
I wrote an Insert trigger than works fine but, the Delete is giving me problems.
Here is the code that does not work:
The error message is "The column prefix 'deleted' does not match with a table name or alias name used in the query".
How do I reference the fields in the 'deleted' table so I only delete this one identical record from the other database table??
I have two databases that are identical (Demodata and Data_01). When a user inserts or deletes a record in a specific table in Demodata, I want to make the same thing happen to the same table in Data_01.
I wrote an Insert trigger than works fine but, the Delete is giving me problems.
Here is the code that does not work:
Code:
CREATE TRIGGER utr_SyncSysCodes_Delete ON demodata.SYCDEFIL_SQL
FOR DELETE
AS
Delete from Data_01.Sycdefil_SQL where
Data_01.Sycdefil_SQL.cd_type = deleted.cd_type AND
Data_01.Sycdefil_SQL.sy_terms_cd = deleted.sy_terms_cd
Go
The error message is "The column prefix 'deleted' does not match with a table name or alias name used in the query".
How do I reference the fields in the 'deleted' table so I only delete this one identical record from the other database table??