In this blog post, let’s learn about the error message “13609 – JSON text is not properly formatted. Unexpected character ‘%lc’ is found at position %d.” in Microsoft SQL Server, the reason why it appears and the solution to fix it.
SQL Server Error Message
13609 – JSON text is not properly formatted. Unexpected character ‘%lc’ is found at position %d.
Reason for the Error
The SQL Server error message 13609 – “JSON text is not properly formatted. Unexpected character ‘%lc’ is found at position %d” occurs when you try to insert JSON data into a column, but the JSON text is not well-formed, meaning it does not conform to the syntax rules of JSON.
JSON is a text-based data format that uses a specific syntax to represent data. JSON data must be formatted correctly to be parsed and used by an application. The error message 13609 indicates that there is an unexpected character in the JSON text at a specific position.
For example, consider the following JSON text:
{ "name": "John", "age": 30, "city": "New York" "state": "NY" }
In this example, a comma is missing after the “city” property. This would result in the error message 13609 with the following details:
- The unexpected character is the letter “s” in “state”
- The position of the unexpected character is 52, which is the position of the “s” in “state”
Solution
To fix this error, you need to correct the JSON text to ensure that it is well-formed. In the example above, you would need to add a comma after the “city” property:
{ "name": "John", "age": 30, "city": "New York", "state": "NY" }
By ensuring that the JSON text is properly formatted, you can avoid the error message 13609 and successfully insert the JSON data into the column.