MSSQLTips.com · November 11, 2025
Load JSON into SQL Server Table
This article demonstrates how to convert semi-structured JSON into relational SQL Server records using the OPENJSON function introduced in SQL Server 2016. It develops reusable stored procedures for three structures: flat arrays of objects, nested objects, and hybrid documents combining parent attributes with child arrays.
The examples use explicit column mappings and JSON paths, CROSS APPLY to flatten nested objects, and a cursor to process department-level arrays while retaining their associated employee records. The discussion also addresses input validation, missing properties, and performance considerations when loading larger JSON documents.