Posts

Showing posts from November 29, 2018

Update table using JSON in SQL

Image
up vote 2 down vote favorite Is there a way to update a table using a JSON field in SQL. { "RelationshipType" : [ { "ID" : 1, "FromID" : 70, "ToID" : 12 }, { "ID" : 3, "FromID" : 80, "ToID" : 1 } ] } Table structure ID | FromID | ToID | 1 | 10 | 12 | 2 | 42 | 17 | 3 | 100 | 1 | If I update the table using the above mentioned JSON file in SQL server the output should be changed as below by matching the FromID to ID . ID | FromID | ToID | 1 | 70 | 12 | 2 | 42 | 17 | 3 | 80 ...