Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

insert json file to mssql

Declare @JSON varchar(max)
SELECT @JSON=BulkColumn
FROM OPENROWSET (BULK 'path to json file', SINGLE_CLOB) import 
-- E.g Path: C:UsersxxxDownloadsData.json

INSERT INTO Person (id, name, surname, age, dateOfBirth)
 SELECT id, firstNAme, lastName, age, dateOfBirth 
 FROM OPENJSON(@json)
 WITH (id int,
       firstName nvarchar(50), lastName nvarchar(50), 
       age int, dateOfBirth datetime2)
Source by www.codeproject.com #
 
PREVIOUS NEXT
Tagged: #insert #json #file #mssql
ADD COMMENT
Topic
Name
5+2 =