Last active
April 2, 2021 10:24
-
-
Save christianarg/0a7afd4382c7637f10d1497472724d97 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
source: https://www.sqlshack.com/import-json-data-into-sql-server/ | |
sample json | |
[ | |
{ | |
"id": "1", | |
"name": "paco" | |
}, | |
{ | |
"id": "2", | |
"name": "jose" | |
}, | |
{ | |
"id": "3", | |
"name": "manolo" | |
} | |
] | |
*/ | |
DECLARE @JSON NVARCHAR(max) | |
SELECT @JSON=BulkColumn | |
FROM OPENROWSET (BULK 'D:\CODE\jsonlist.json', SINGLE_CLOB) import | |
SELECT * INTO JSONTable | |
FROM OPENJSON (@JSON) | |
WITH | |
( | |
id NVARCHAR(5), | |
name NVARCHAR(50) | |
) | |
SELECT * FROM JSONTable |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment