Created
February 19, 2017 13:43
-
-
Save bertwagner/72bae57d890d8b4b41b6bb9f708afee4 to your computer and use it in GitHub Desktop.
Test data for SQL performance comparison (truncated)
This file contains hidden or 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
-- Car data source: https://github.com/arthurkao/vehicle-make-model-data | |
IF OBJECT_ID('dbo.Cars') IS NOT NULL | |
BEGIN | |
DROP TABLE dbo.Cars; | |
END | |
CREATE TABLE dbo.Cars | |
( | |
Id INT IDENTITY(1,1), | |
CarDetails NVARCHAR(MAX) | |
); | |
-- See https://gist.github.com/bertwagner/1df2531676112c24cd1ab298fc750eb2 for the full untruncated version of this code | |
DECLARE @cars nvarchar(max) = '[ {"year":2001,"make":"ACURA","model":"CL"}, {"year":2001,"make":"ACURA","model":"EL"},...]'; | |
INSERT INTO dbo.Cars (CarDetails) | |
SELECT value FROM OPENJSON(@cars, '$'); | |
SELECT * FROM dbo.Cars; | |
/* | |
Output: | |
Id CarDetails | |
----------- ---------------------------------------------- | |
1 {"year":2001,"make":"ACURA","model":"CL"} | |
2 {"year":2001,"make":"ACURA","model":"EL"} | |
3 {"year":2001,"make":"ACURA","model":"INTEGRA"} | |
... | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment