Read JSON Data in MSSQL from Different Rows
hi!
I tried to replace and other methods but it was too hard and I found this.Mssql has a method named OPENJSON
Basicly this method working like json.parse(…) in javascript. I will give an example (you should define your variables in JSON otherwise the query returns object)
SELECT * FROM OPENJSON(‘[{“name”:”BİNEK”},{“name”:”ECUTEST”}]’)
WITH (value NVARCHAR(50) ‘$.name’);
If you want to use this for more than 1 row you should use cross apply. My all data is 30k and this is my row headers
I want to find how many categories in this customer data because I will create a categorization algorithm.
SELECT DISTINCT value
distinct for make singular all categories types
FROM #t
#t it is a temp table I pushed not null kategori rows
CROSS APPLY(kategori,'$') WITH(value NVARCHAR(50) '$.name')
ORDER BY value ASC
I hope it will help to solve your read from json problem