4

I created linked server between sql server and mysql.It will work fine for me. My question is when insert row in mysql table that time i want to update row in sql server table,

Like in mysql table name 'abc' when in this table new row insert that time in ms sql server table name is xyz and in this field name status by default true and when new row insert in the abc table that time in xyz table field name status will automatically update and status will change to false.

My linked server name is MYLINK and it will work fine for me , I want to create trigger which update row in sql server,and how to create trigger for update row in the ms sql server.

1
  • 3
    The question probably interesting, but I think you will have to edit it in order to make things much more clear if you want accurate answers. Commented Aug 8, 2013 at 9:02

2 Answers 2

1
ALTER TRIGGER [TriggerLocalServerTable]
   ON  dbo.[LocalServerTable]
    FOR INSERT
AS 

DECLARE @A varchar(4)
DECLARE @B varchar(4)
DECLARE @id int

BEGIN
 SELECT
 @A = A,
 @B = B,
 @id = id
 FROM inserted

 UPDATE  [LinkedServer].[Database].[dbo].[Table]
 SET A = @A, B = @B
 WHERE id = @id      
END
Sign up to request clarification or add additional context in comments.

Comments

1

mysql cannot trigger anything else but mssql. But you can use SQL Agent to schedule a task, executed on sql server to select data from the linked mysql

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.