A Scalar valued function that will set and manipulate json object in Sql Server Management Studio 2019.We need to pass JSON Object ,it's Path and value that need to be set with it's type.
Open and view the Project using the .zip file provided or at my Github Repository.
This project was built from scratch using SQL Features.
No additional tools are required apart from a text editor of your choice
No additional installation is required for this project
- Create a new Scalar function with the following:
- Use the Required database.
- Execute the Function.
For details now how everything has been implemented, refer the source code.
- Will allow to create JSON path if the path is not present.
- Will Update the value based on it's type.
- Better than
json_modifyif we provide them path that is not presenet it will give us error.
- Open the project through the
.zipfile provided and extract the files.Open
JSONMapper_function.sqlin the Sql Server Management Studio and execute it on desired database.
- use the following lines to run the SQL Server Management Query.The function contains the following types 'boolean','numeric','array','string','object'.
Declare @JSON varchar(100) = '{ "employee": { "name":"sonoo"} }'
select @JSON= dbo.JSONMapper(@JSON,'employee.ssn','AAA-GG-SSSS','string') /*this line is used to set the JSON object*/
select @JSON as Output