Question: I have a situation where I have to call a a javascript method from SQL Server. I haven't found any solution to do the same. I found one thing that I can call web service from SQL Server but now the problem is "Can we call javascript function from web service (like we can do in code behind file of aspx page)"?

Please help

Answer: 
You could do this using [Server-Sent Events](http://www.w3.org/TR/eventsource/), which are supported in most recent browsers.

The PHP:

```
header('Content-Type: text/event-stream');
header('Cache-Control: no-cache');

echo "id: " . time() . " " . PHP_EOL;
echo "data: $message" . PHP_EOL;
echo PHP_EOL;
ob_flush();
flush();

```

The JS:

```
var source = new EventSource('/php');
source.onmessage = function(e) {
    console.log(e.data);
};

```
No, you can't call a javascript function on the **client** from a web service on a **server**.