I can't find any information if I can reference outside table column while trying to convert JSON data in a table format.
An example:
-- create temp table for data
create local temporary table #test("StorageId" INT, "Items" nvarchar(200));
-- insert 1 test data
insert into #test("StorageId", "Items")
values(1, '[22,33]');
-- query used for converting the json data to table where im passing the json column from the outside table
SELECT e."StorageId"
FROM #test AS e
where 22 in (
select "ItemId" from JSON_TABLE(e."Items", '$[*]' COLUMNS ("ItemId" INT PATH '$'))
)
And this query returns error:
(dberror) [259]: invalid table name: table does not exist > E:
If I put the array string instead of the outside table column then the query executes:
select e."StorageId"
from #test AS e
where 22 in (
select "ItemId" from JSON_TABLE('[22,33]', '$[*]' COLUMNS ("ItemId" INT PATH '$'))
)