Alexandre Nizoux
Alexandre Nizoux

Reputation: 216

Bash or PHP script to execute stored procedure on SQL Server

I am trying to write a bash or PHP script that will execute a procedure on a MS-SQL Server. Does anybody have pointers on how to do that in the easiest and most convenient way?

The script will run on a separate Linux box.

Upvotes: 0

Views: 1076

Answers (3)

Svetlozar Angelov
Svetlozar Angelov

Reputation: 21660

Installing the php mssql drivers (on Linux) can become a real pain. Just take that in mind.

We had to deal with a hosting company, which refused to install them. I ended up with a wcf service (installed as a windows service) on the sql server machine, which just invokes the sp and a simple http request from the php script. I think it is quite cool actually.

I realize that a lot of people would qualify that as an absolute overkill, but there is no doubt that an http request can be performed from a lot of devices and platforms. You don't have to install the sql drivers on every machine and platform you need to execute the sp.

That way you don't have to 'open' the sql server for remote connections, but you host wcf service (which is not more secure or anything... just a difference, some people get crazy when hear about allowing sql remote connections)

Upvotes: 1

ghostdog74
ghostdog74

Reputation: 342373

you can use mssql class for PHP.

Upvotes: 0

CodeMonkey1313
CodeMonkey1313

Reputation: 16011

Here is an example of how to execute a sproc in PHP.

Upvotes: 0

Related Questions