I have a procedure which call another procedure in it and return a json result by the inner procedure in sql server.How I can retrieve the json result(from inner procedure) and store it in a temporary table.Please help me.I do in this way,but got an error
"The FOR JSON clause is not allowed in a INSERT statement."
DECLARE @EquipmentId NUMERIC(18,0)
DECLARE @EquipmentDetails table
(
EquipmentName VARCHAR(50),
EquipmentCode VARCHAR(15),
EquipmentTypeName VARCHAR(50),
)
SELECT @EquipmentId=Equipment_ID FROM Prime.Requisition WHERE ID=1
INSERT INTO @EquipmentDetails
EXECUTE [Prime].[Get_ReqSpares_EquipmentDetails] @EquipmentId
None
0 Points
18 Posts
INSERT JSON RESULT TO A TEMPORARY TABLE
Jan 28, 2020 10:45 AM|SinjuRenny|LINK
I have a procedure which call another procedure in it and return a json result by the inner procedure in sql server.How I can retrieve the json result(from inner procedure) and store it in a temporary table.Please help me.I do in this way,but got an error "The FOR JSON clause is not allowed in a INSERT statement."
DECLARE @EquipmentId NUMERIC(18,0)
DECLARE @EquipmentDetails table
(
EquipmentName VARCHAR(50),
EquipmentCode VARCHAR(15),
EquipmentTypeName VARCHAR(50),
)
SELECT @EquipmentId=Equipment_ID FROM Prime.Requisition WHERE ID=1
INSERT INTO @EquipmentDetails
EXECUTE [Prime].[Get_ReqSpares_EquipmentDetails] @EquipmentId
Contributor
3140 Points
983 Posts
Re: INSERT JSON RESULT TO A TEMPORARY TABLE
Jan 29, 2020 02:56 AM|Yang Shen|LINK
Hi SinjuRenny,
A solution for your current situation can not be provided since the information is not enough.
But you can check this similar case, use CTE seems can solve the problem and you can have a try.
Best Regard,
Yang Shen