Hii to all
I have a requirement that,i have two tables (i)mainlog,present in sqlserver(ii)sparelog,present in MySql which is present in different server location.I need to write a trigger to copy a mainlog table data to sparelog table.when ever any DML operation
is performed to mainlog table the trigger has to fire automatically and reflect the same to sparelog table present in different server location.I have already created a Linkedserver to Mysql from my local Sqlserver.
I have tried by writing the following trigger and successfully copied the table data from mainlog table to sparelog table for only insert operation,and with in the same instance of sqlserver:-
CREATE TRIGGER MYSQLLogRecords
ON mainlog
FOR INSERT
AS
BEGIN
SET NOCOUNT ON
IF EXISTS(SELECT *FROM mainlog)
--BEGIN
INSERT OPENQUERY(MYSQL,'SELECT * FROM users.nsparelog')
SELECT * FROM inserted
ELSE
INSERT OPENQUERY ...
Go to the complete details ...