Click here to Skip to main content
15,890,336 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using sql server 2012.I have been assigned a task where one of my column(JsonText) of table(Sample) contain json data.I want to parse that data and insert into columns of another table(Test).I searched on net openjson is supported in sql server 2016.How to do in sql server2012.

Table1 : Sample
Id JsonText Active

JsonText
webaddress?{'data':'{"PId": "XXXX","Status": "YES","Name":"XXX","Address":"XXXX","MobileNumber":"xxx"}'}

I am intrested only 'PID,Address,MobileNumber' columns not all.

Table Test structure like this
Id,PID,Address,MobileNumber

What I have tried:

I tried with openjson funtion but that is not supported in sql server 2012.
Posted
Updated 17-Mar-19 22:25pm
Comments
Member 9831003 12-Dec-16 4:07am    
try with xml data type. Check below link may be help full
http://stackoverflow.com/questions/2497678/storing-json-in-an-mssql-database

You will need a custom function in order to run on pre-2016 version of sql server, check out this Programming Example: Parse JSON String by SQL script[^] and its excellent references.
 
Share this answer
 
 
Share this answer
 
Comments
Richard Deeming 21-Mar-19 13:34pm    
That's the same link referenced by the post linked to in solution 1.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900