<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>json_query &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/tag/json_query/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.dbrnd.com</link>
	<description>BIGData &#124; NoSQL &#124; MSSQL &#124; MySQL &#124; PostgreSQL</description>
	<lastBuildDate>Wed, 23 Aug 2017 18:10:04 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.6</generator>
	<item>
		<title>SQL Server 2016: Introduced JSON support, to store and retrieve JSON document</title>
		<link>https://www.dbrnd.com/2016/12/sql-server-2016-introduced-json-support-to-store-and-retrieve-json-document-isjson-json_value-json_query/</link>
					<comments>https://www.dbrnd.com/2016/12/sql-server-2016-introduced-json-support-to-store-and-retrieve-json-document-isjson-json_value-json_query/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Sat, 10 Dec 2016 19:51:08 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[isjson]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[json_query]]></category>
		<category><![CDATA[json_value]]></category>
		<category><![CDATA[NoSQL]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server Administrator]]></category>
		<category><![CDATA[SQL Server Monitoring]]></category>
		<category><![CDATA[SQL Server Performance Tunning]]></category>
		<category><![CDATA[SQL Server Tips and Tricks]]></category>
		<category><![CDATA[TSQL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=4025</guid>

					<description><![CDATA[JSON + RDBMS is one of the interesting topics, in the new version of SQL Server 2016 we can store JSON formatted data. Now a day JSON data type is a standard feature for all new coming RDBMS product versions like PostgreSQL 9.4, and MySQL 5.7 have already introduced this. Now We can say, we [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F12%2Fsql-server-2016-introduced-json-support-to-store-and-retrieve-json-document-isjson-json_value-json_query%2F&amp;linkname=SQL%20Server%202016%3A%20Introduced%20JSON%20support%2C%20to%20store%20and%20retrieve%20JSON%20document" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F12%2Fsql-server-2016-introduced-json-support-to-store-and-retrieve-json-document-isjson-json_value-json_query%2F&amp;linkname=SQL%20Server%202016%3A%20Introduced%20JSON%20support%2C%20to%20store%20and%20retrieve%20JSON%20document" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F12%2Fsql-server-2016-introduced-json-support-to-store-and-retrieve-json-document-isjson-json_value-json_query%2F&amp;linkname=SQL%20Server%202016%3A%20Introduced%20JSON%20support%2C%20to%20store%20and%20retrieve%20JSON%20document" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F12%2Fsql-server-2016-introduced-json-support-to-store-and-retrieve-json-document-isjson-json_value-json_query%2F&amp;linkname=SQL%20Server%202016%3A%20Introduced%20JSON%20support%2C%20to%20store%20and%20retrieve%20JSON%20document" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F12%2Fsql-server-2016-introduced-json-support-to-store-and-retrieve-json-document-isjson-json_value-json_query%2F&amp;linkname=SQL%20Server%202016%3A%20Introduced%20JSON%20support%2C%20to%20store%20and%20retrieve%20JSON%20document" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F12%2Fsql-server-2016-introduced-json-support-to-store-and-retrieve-json-document-isjson-json_value-json_query%2F&amp;linkname=SQL%20Server%202016%3A%20Introduced%20JSON%20support%2C%20to%20store%20and%20retrieve%20JSON%20document" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F12%2Fsql-server-2016-introduced-json-support-to-store-and-retrieve-json-document-isjson-json_value-json_query%2F&#038;title=SQL%20Server%202016%3A%20Introduced%20JSON%20support%2C%20to%20store%20and%20retrieve%20JSON%20document" data-a2a-url="https://www.dbrnd.com/2016/12/sql-server-2016-introduced-json-support-to-store-and-retrieve-json-document-isjson-json_value-json_query/" data-a2a-title="SQL Server 2016: Introduced JSON support, to store and retrieve JSON document"></a></p><p>JSON + RDBMS is one of the interesting topics, in the new version of SQL Server 2016 we can store JSON formatted data.</p>
<p>Now a day JSON data type is a standard feature for all new coming RDBMS product versions like PostgreSQL 9.4, and MySQL 5.7 have already introduced this.</p>
<blockquote><p>Now We can say, we have SQL Server 2016 with the RDBMS + NoSQL concepts.<br />
We can store JSON data as nvarchar, but the JSON related functions have the advantage of enforcing that each stored value is valid according to the JSON rules.</p></blockquote>
<p><strong>Small demonstration on SQL Server 2016 JSON:</strong></p>
<p><strong>Create a sample table and define two column as NVARCHAR to store JSON data:</strong></p><pre class="crayon-plain-tag">CREATE TABLE tbl_TestSQLJSON
(
	ID INTEGER PRIMARY KEY
	,DepartmentName VARCHAR(250)
	,EmployeeName NVARCHAR(MAX)
	,EmployeeAddress NVARCHAR(MAX)
)
GO</pre><p> </p>
<p>Use ISJSON() and add check constraint in json columns:<br />
If your json format and document is correct, It returns true other It returns false.</p><pre class="crayon-plain-tag">ALTER TABLE tbl_TestSQLJSON
ADD CONSTRAINT ck_tbl_TestSQLJSON_EmployeeName
CHECK (ISJSON( EmployeeName ) &gt; 0)
GO

ALTER TABLE tbl_TestSQLJSON
ADD CONSTRAINT ck_tbl_TestSQLJSON_EmployeeAddress
CHECK (ISJSON( EmployeeAddress ) &gt; 0)
GO</pre><p> </p>
<p>Insert few sample JSON data:</p><pre class="crayon-plain-tag">INSERT INTO tbl_TestSQLJSON
VALUES 
(
	1
	,'Sales'
	,N'{"firstName": "Anvesh", "lastName": "Patel"}'
	,N'
	{"address" : 
		{ 
			"India": "Hyderabad"
			,"USA": "Newyork"
		}
	}'
)
,(
	2
	,'Production'
	,N'{"firstName": "Neevan", "lastName": "Patel"}'
	,N'
	{"address" : 
		{ 
			"India": "Ahmedabad"
			,"USA": "Washington DC"
		}
	}'
)
,(
	3
	,'Animation'
	,N'{"firstName": "Eric", "lastName": "Lorn"}'
	,N'
	{"address" : 
		{ 
			"India": "Mumbai"
			,"USA": "Chicago"
		}
	}'
)
GO</pre><p> </p>
<p><strong>SELECT json data:</strong></p><pre class="crayon-plain-tag">SELECT 
	ID
	,DepartmentName
	,JSON_VALUE(EmployeeName, '$.firstName') AS EmployeeFirstName     
	,JSON_VALUE(EmployeeAddress, '$.address.India') AS AddressIndia
	,JSON_VALUE(EmployeeAddress, '$.address.USA') AS AddressUSA
	,JSON_QUERY(EmployeeAddress, '$.address') AS EmployeeAddressJSON
FROM tbl_TestSQLJSON
GO</pre><p> </p>
<p><strong>Use JSON_VALUE() in WHERE Clause:</strong></p><pre class="crayon-plain-tag">SELECT 
	ID
	,DepartmentName
	,JSON_VALUE(EmployeeName, '$.firstName') AS EmployeeFirstName     	
FROM tbl_TestSQLJSON
WHERE JSON_VALUE(EmployeeName, '$.firstName') = 'Anvesh'
GO</pre><p> </p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2016/12/sql-server-2016-introduced-json-support-to-store-and-retrieve-json-document-isjson-json_value-json_query/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
