October 4, 2017 at 8:29 am
I was just curious, is there a reason there is not a JSON data type?
XML has an XML data type... why not have that for JSON as well?
*I was hoping someone had read a blog or seen a talk about this, I tried to search but it was difficult to get the desired hits on Google.
Thanks!
October 4, 2017 at 8:36 am
Maxer - Wednesday, October 4, 2017 8:29 AMI was just curious, is there a reason there is not a JSON data type?XML has an XML data type... why not have that for JSON as well?
*I was hoping someone had read a blog or seen a talk about this, I tried to search but it was difficult to get the desired hits on Google.
Thanks!
Because...
https://blogs.msdn.microsoft.com/jocapc/2015/05/16/json-support-in-sql-server-2016/
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
October 4, 2017 at 8:47 am
Although I'll admit, maybe it is a bit odd, but it is easy to add a constraint on a JSON column:--Create sample table
CREATE TABLE SampleJson (JsonString varchar(max));
GO
--Add Constraint
ALTER TABLE SampleJson ADD CONSTRAINT ValidJson CHECK (ISJSON(JsonString) > 0);
GO
--This will fail
INSERT INTO SampleJson
VALUES ('test');
GO
--This will work
INSERT INTO SampleJson
VALUES (
'{
"a":"[1,2]",
"b":"[3,4]",
"c":"[5,6]"
}');
GO
--Clean up
DROP TABLE SampleJson;
GO
I can't say I've seen much (any) discussion on the subject though. I have no use for JSON in the "real world" so I've not really kept an eye on discussions on it.
Thom~
Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
Larnu.uk
October 4, 2017 at 8:50 am
I think the adoption of the XML type was really low. For the reasons in the blog, lots of people kept XML in nvarchar/varchar columns, and just used some of the functions to query them. I think this is better, rather than investing in a native type, see what the uptake is. They can always add it later.
October 4, 2017 at 9:52 am
Ah ok that all makes a lot of sense (all the replies) thanks!!
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply