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.

peterm
  • 91,357
  • 15
  • 148
  • 157
Panchotiya Vipul
  • 1,226
  • 5
  • 17
  • 42
  • 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. – Sylvain Leroux Aug 08 '13 at 09:02

2 Answers2

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

Vijay
  • 8,131
  • 11
  • 43
  • 69
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
Sudharsun
  • 741
  • 6
  • 23