Searching JSON columns in MSSQL

SQL server

Assume there is a table "Settings" with a column "SVal" which is of type nvarchar(MAX) and stores JSON strings, e.g. { "Lang": "en" }. We can search this table, for specific JSON values as following:


SELECT * FROM Settings WHERE JSON_VALUE(SVal, '$.Lang') = "en"

More information can be found here: https://learn.microsoft.com/en-us/sql/t-sql/functions/json-value-transact-sql?view=sql-server-ver16

Post a Comment

Previous Post Next Post