Editorials

Microsoft Brings JSON to SQL Server

SQL Server 2016 is being enhanced to support JSON, much like they did when they added XML capabilities. I find this intriguing. Are they intending that SQL Server be an endpoint for REST clients? That would require endpoints and exposing your database server to consumers. I’m not sure I’m on board. It may save some work…but is it worth the risk? Do we really need to put translation loads on our precious, limited resource, the SQL Service?

It isn’t that difficult to build a REST layer using technologies already available. Entity Framework translates database results from data tables into objects with ease. POCOs (Plain old CLR Objects) are readily converted into JSON with libraries already common place for most developers. In fact, using ASP.Net, the translation of POCOs to JSON is already a native part of the communication libraries between a REST client and a web server.

So I don’t get it. Why put the load on your database server, of taking a data table and converting it into JSON? If I do that work on my web server, or any other layer for that matter, I can scale out to my hearts desire. Placing this load on my database server means it can only run in one place. And while I am using resources to convert TDS streams (Tabular Data Streams, the data communication protocol built into SQL Server by Sybase decades ago) into JSON, I am not performing database actions.

Here is what I see coming out of this. Developers will find that they can pass parameters to stored procedures as a blob, consisting of JSON data. They will start using this as a technique to pass, not necessarily sets, but multiple input parameters. This is what many developers still do today, using an XML parameter instead of correctly designing their input parameters as typed, well know inputs. This resuls in chaos; it increases the complexity of stored procedures, masks the intent of the input, and does not provide any checking of the input data at compile time, because the input is not well defined.

Let’s not start doing this same thing with JSON. Listen to the Robot from “Lost in Space!” “Warning, Will Robinson, Warning!”

Just because something is cool doesn’t mean it should be done. Even if other vendors have done it before you. As a consumer, just because a product supports something, doesn’t mean it should be used. Don’t get me wrong, there is a LOT to be excited about in the 2016 SQL Server release. For me, this just isn’t one.

Cheers,

Ben