Validate data is in JSON format in MS SQL Server

Check data is in JSON format in MS SQL Server

ISJSON is used to check the JSON value in MS SQL Server is valid or not. If the value is valid then it will return 1 otherwise 0.

Check the JSON value in MS SQL Server is a valid JSON value


-- JSON valid format
select isjson('{"id": "1"}') as Result
Result
------
1

--NON-JSON format
select isjson('abc') as Result
Result
-------
0

Check the column data with valid JSON format:

Check the invalid data in the column which does not contain JSON format data:

select docjson from customerdoc where isjson(docjson) = 0;
Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.