TSQL Function to Split JSON Data
Posted by Dan | Posted in Databases, SQL Server | Posted on 09-24-2009
2
SQL Server Central has a great function that converts a JSON string into a table. Worth checking out! (Unfortunately you have to register to see it, but it’s free.)
Function looks like this
1 2 3 | -- object example, braces surround the name:value objects SELECT id, name, VALUE FROM dbo.fnSplitJson2('{Apples:20000,Oranges:400,Apricots:507}',NULL) |
Which returns a table:
1 2 3 4 | id name value 1 Apples 20000 2 Oranges 400 3 Apricots 507 |

























I really like SQLServerCentral. I’ve gotten lots of good information from them, and the Question of the Day has been a great way to learn a little tidbit or two with my morning coffee.
Cheers,
YES! Question of the day is like the first thing I look at when I wake up and see my iPhone. Great site!