JSON Support in SQL Server 2016

Just seen a blog from Aaron Bertrand about JSON support in SQL SERVER 2016. In my last job we wanted to export some data stored in SQL SERVER into Elasticsearch and converting large amounts of data into JSON documents was quite tricky to get working at first. There are lots of other database applications that store their data as JSON, for example, MongoDB and this looks like it will be helpful loading data from SQL SERVER into these if needed. Microsoft have got their own rival for the likes of MongoDB named DocumentDB and this stores its documents in JSON so I guess this JSON support is something they needed to add.

Getting Started with MongoDB

I’ve only ever used SQL Server and am only familiar with relational databases.  You’ve probably heard all the talk about NoSQL and I thought I’d have a quick look at MongoDB which saves data in JSON documents rather than in relational format.

I’ve just managed to install it and set it up as a service running on Windows and it seems to work with out any problems.  Here are the instructions I followed

http://docs.mongodb.org/manual/tutorial/install-mongodb-on-windows/

I extracted the contents of the download to

D:\mongodb

and saved the following in a batch file so I can just double click to connect.

D:\mongodb\bin\mongo.exe

Just type “exit” to exit.

There is a very quick example of how to add and extract data on this page

db.test.save( { a: 1 } )
db.test.find()

When you run the find() command you’ll see that you get an “_id” field back. This is the unique identifier for the document, equivalent to a primary key in SQL. You can set this value in the document you save, for example

db.test.save( {_id: 1, a: 1 } )

That’s as far as I’ve got so far but I’ve also just signed up to “M101J: MongoDB for Java Developers” in https://education.mongodb.com/. It’s been 14 years since I last looked at any Java code so it might be a struggle.