Pass Json_value Into Stored Procedure
I am trying to parse JSON and pass the key-value pairs into a stored procedure. declare @json nvarchar(max) = '{'bin':1,'type':'A'}', @id int = 1234 exec someStoreProcedure select
Solution 1:
-- Inputs
declare @json nvarchar(max) = '{"bin":1,"type":"A"}',
@id int = 1234
-- Map json to variables
declare @bin int = json_value(@json, '$.bin')
declare @type nvarchar(10) = json_value(@json, '$.type')
-- Pass variables into procedure
exec someStoreProcedure select
@bin,
@type,
@id
Post a Comment for "Pass Json_value Into Stored Procedure"