JavaScript objects serialized into JavaScript Object Notation (JSON) has a lot of power in the transportability of fully functional transmission of data and logic in an encapsulated form. As we have been discussing, JSON is now a first class citizen in SQL Server when it comes to JSON encapsulated data, but not the JavaScript methods also included in the JSON specification. It seems to me that this is a opportunity, something for which I don’t have a current use case, where the ability of SQL Server to utilize CLR, Dot Net code, can interact with the JSON serialized objects are more than just data.

So, here’s the theory. JSON has the ability to embed JavaScript code. In the native TSQL code you cannot execute any embedded JavaScript. However, using Dot Net code, you could execute the JavaScript code and interact with the results.

This whole theory breaks down when you have to try and interact with JavaScript in Dot Net. The problem as I am able to understand it is that you can only execute JavaScript in a browser…at least to the best of my research to this point. So, in CLR code you would have to use a Dot Net Browser control in order to interact with JavaScript. If you did use a Browser control in Dot Net, it wouldn’t have to be visible to be used. However, it would expose the necessary pipeline to communicate from C# or Visual Basic to the Browser Control, and therefore the JavaScript methods and variables.

Like I said earlier, this is really just a thought experiment. Could something be plugged together to allow SQL Server to interact with JavaScript methods and variables? I don’t really have a need to do anything like this. In fact, I do have concerns that the components that would be necessary would have potential for memory leaks, and not be a viable implementation in a SQL Server installation.

So, let’s say we can work out all of the logistics to implement a solution, how would you take advantage of this kind of capability? Are there features of an application you could enable in a single code base with this kind of technology? Do you think you could come up with something like data validation that could be used in all layers of code?

What do you think? Share your thoughts in our comments?

Cheers,

Ben