Last active
February 6, 2017 22:05
-
-
Save bertwagner/509e826d0306b74be33d94a034472f13 to your computer and use it in GitHub Desktop.
SQL Server 2016 JSON's direct JSON string creation
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
-- The most primative way of creating JSON in SQL. We don't want to have to do this | |
DECLARE @garage nvarchar(100) = '{ "Cars" : [{ "Make" : "Volkswagen"}, { "Make" : "Subaru"}] }' | |
-- But it works! | |
SELECT @garage | |
-- Output: { "Cars" : [{ "Make" : "Volkswagen"}, { "Make" : "Subaru"}] } | |
-- And with our SQL 2016 ISJSON() function we can check that the JSON string is valid | |
SELECT ISJSON(@garage) | |
-- Output: 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment