Skip to content

Instantly share code, notes, and snippets.

@ptdel
Last active February 24, 2021 22:27
Show Gist options
  • Save ptdel/d5cd9306567ace0044777009b0d6a1cd to your computer and use it in GitHub Desktop.
Save ptdel/d5cd9306567ace0044777009b0d6a1cd to your computer and use it in GitHub Desktop.
load JSON into table with GUID primary key
DECLARE @json NVARCHAR(MAX) = N'{"json":"here"}';
INSERT INTO tableName (Id, columnA, columnB, ...)
SELECT NEWID(), * FROM OPENJSON(@json)
WITH (
columnA VARCHAR(255) '$.columnA',
columnB VARCHAR(255) '$.columnB',
...
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment