我正在从服务器获取这样的数组:
["Sports", "Life"]
并且SQL Server抛出诸如以下错误:
JSON文本格式不正确。在位置1“处发现意外字符'''
我的代码:
DECLARE @data VARCHAR(100) = ["Sport","Life"]
SELECT *
FROM skills
WHERE EXISTS (SELECT 1
FROM OPENJSON(@data, '$') AS j
WHERE skills.description LIKE '%' + j.value + '%')
答案 0 :(得分:0)
您的字符串设置错误:
DECLARE @data VARCHAR(100) = ["Sport","Life"]
应该是
DECLARE @data VARCHAR(100) = '["Sport","Life"]'