How can I run a php script ( to run a REST) command from within an MSSQL trigger?
I need this to run a REST command from a remote webservice just after a user logged in.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Are you sure you want to do this in the database layer?
Do you want your DB transaction to wait (and hold locks) while your REST request comes back? What happens if your web service is running slowly and times out after 1 minute?
It’s possible but again, use with caution.
In SQL Server, there is an extended stored procedure called
XP_CMDSHELLwhich will allow you to run scripts on the command line.http://msdn.microsoft.com/en-us/library/ms175046.aspx
It’s disabled by default but you can enable it like so:
Then in your trigger, you can call your script:
If you must do this in the database, I would strongly suggest just porting your php script to a .net language and executing it as a CLR stored procedure. That would be much more secure and less likely to cause problems.