I want to know if we can create a trigger in MS SQL server which triggers a php script on each insertion of record
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 ;
I feel it break multilevel architecture and bad idea
If it local php script, must be possible use exec
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.
If it remote PHP, good solution pointed in Can you call a webservice from TSQL code?