SQL SEVER: Counting Jason Array Size

Assuming your table is named error_log and the column containing the JSON string is error_data, and the JSON structure is like this:

{
  "error_code": "some_code",
  "error_message": ["message1", "message2", ...]
}

Your SQL Server query would look like this:

SELECT JSON_VALUE(error_data, '$.error_code') AS error_code, (SELECT COUNT(*) FROM OPENJSON(error_data, '$.error_message')) AS error_message_count FROM error_log;