Wondering if anyone can work out what's wrong with this, I keep getting this error when reading the table from another database other than [HubSpotCache] (still in the same SQL instance).
Msg 319, Level 15, State 1, Line 33
Incorrect syntax near the keyword 'with'. If this statement is a common table expression, an xmlnamespaces clause or a change tracking context clause, the previous statement must be terminated with a semicolon.
SELECT
J.label
FROM
[HubSpotCache].dbo.[ContactProperties] C
CROSS APPLY
OPENJSON(C.[OptionsAggregate])
WITH (
label NVARCHAR(100) N'$."value"'
) AS J
WHERE
ISJSON(C.[OptionsAggregate]) > 0
Here's the value in OptionsAggregate column of the table
[
{
"label": "China",
"value": "China",
"displayOrder": -1,
"doubleData": 0.0,
"hidden": false,
"readOnly": false
},
{
"label": "Singapore",
"value": "Singapore",
"displayOrder": -1,
"doubleData": 0.0,
"hidden": false,
"readOnly": false
}
]