Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

We have a website that stores form data in a web hosted MySQL database. Whenever form data is entered into the MySQL server tables I need update all necessary tables on our local SQL Server database.

I have seen several articles that describe how to update MySQL using SQL Server triggers but nothing that goes the other way.

If I create a linked server and linked tables in SQL Server can I create a trigger on a MySQL table from the SQL Server management studio?

share|improve this question
add comment

1 Answer

You can't "see" the SQL Server from within MySQL like you can in the reverse direction with a linked server.

The only way I can think of doing this is to create a MySQL trigger that calls a User Defined Function that executes an external application and passes the new data to it. The external application would have to connect to the SQL Server database and push the data to it.

DELIMITER @@

CREATE TRIGGER Test_Trigger 
AFTER INSERT ON MyTable 
FOR EACH ROW
BEGIN

DECLARE cmd CHAR(255);
DECLARE result int(10);
SET cmd=CONCAT('/usr/bin/php ', 'home/sync/send_to_sql_server.php f1=', NEW.f1, ' f2=', NEW.f2);
SET result = sys_exec(cmd);

END;
@@
DELIMITER ;
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.