I'm trying to insert all the fields with a specific id into a table, I get this data from a select, I want to put them in a table to make queries with the data in this table as a reference. This is what I have
declare @json varchar(max) = 'esto es un json del diablo'
---SELECT DISTINCT parent_id, NAME, stringValue
--FROM parseJSON(@json)
SELECT DISTINCT *
FROM parseJSON(@json)
--WHERE parent_ID = 1
select min(parent_id) as p_id
from parseJSON(@json)
group by parent_id
having min(parent_id) = max(parent_id)
order by parent_id
-- hasta aquí todo bien esta consulta me da los ids
-- que existen dentro del json, pero ahora necesito
-- tomar esto valores y agregarlos a idstemp
IF OBJECT_ID('idstemp') is not null DROP TABLE idstemp
CREATE TABLE idstemp(
id int
);
Insert into idstemp
(id)
values
(
select min(parent_id) as p_id
from parseJSON(@json)
group by parent_id
having min(parent_id) = max(parent_id)
order by parent_id
)