1

I want to know if we can create a trigger in MS SQL server which triggers a php script on each insertion of record

2 Answers 2

1

Not sure why you want it, but try something in the line of:

DELIMITER @@

CREATE TRIGGER SomeTrigger 
AFTER INSERT ON SomeTable 
FOR EACH ROW 
BEGIN
   DECLARE cmd CHAR(255);
   DECLARE result int(10);
   SET cmd=CONCAT('sudo /path/to/php -f file.php');
   SET result = sys_exec(cmd);
END;
@@
DELIMITER ;
Sign up to request clarification or add additional context in comments.

Comments

0
  1. I feel it break multilevel architecture and bad idea

  2. If it local php script, must be possible use exec

  3. If You don't need synchronous execution, You can in trigger add info to special table, and periodically check it from outside of SQL server. More this don't break architecture.

  4. If it remote PHP, good solution pointed in Can you call a webservice from TSQL code?

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.