First create one database and then create one table into it.
Code:
use tempdb
CREATE TABLE dbo.SystemRecord(
RecordedDateTime datetime2(0) NOT NULL,
RecordedDateTimeLocal datetime2(0) NOT NULL
)
Then create one stored procedure with one string parameter and write your code to insert data into a table.
Code:
CREATE PROCEDURE dbo.InsertSystemRecordData
@json NVARCHAR(max)
AS
BEGIN
INSERT INTO dbo.SystemRecord (
[RecordedDateTime],
[RecordedDateTimeLocal]
SELECT
RecordedDateTime,
RecordedDateTimeLocal
FROM OPENJSON(@json)
WITH (
RecordedDateTime DATETIME2(0) '$.dateTime',
RecordedDateTimeLocal DATETIME2(0) '$.dateTimeLocal'
) AS jsonValues
END
After that execute the stored procedure by passing JSON as an INPUT parameter.
Code:
EXEC dbo.InsertSystemRecordData @json ='{"dateTime":"2018-03-19T15:15:40.222Z","dateTimeLocal":"2018-03-19T11:15:40.222Z"}'
You can also check inserted data insert successfully or not with this query.
Code:
select * from dbo.SystemRecord