TSQL Function to Split JSON Data

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

Leave a Reply