<?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>FOR JSON AUTO &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/tag/for-json-auto/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:13:20 +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: Generate the JSON formatted data from the Table Data</title>
		<link>https://www.dbrnd.com/2017/08/sql-server-2016-generate-the-json-formatted-data-from-the-table-data-for-json-auto/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Thu, 31 Aug 2017 16:16:22 +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[FOR JSON AUTO]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server 2016]]></category>
		<category><![CDATA[SQL Server Administrator]]></category>
		<category><![CDATA[SQL Server Error]]></category>
		<category><![CDATA[SQL Server Monitoring]]></category>
		<category><![CDATA[SQL Server Performance Tuning]]></category>
		<category><![CDATA[SQL Server Programming]]></category>
		<category><![CDATA[SQL Server Tips and Tricks]]></category>
		<category><![CDATA[TSQL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=6008</guid>

					<description><![CDATA[SQL Server 2016 introduced compelling data type called JSON data type. It also added a variety of new operators and functions related to JSON data type. This is one of the interesting topics for us, and I have recently published a series of articles on SQL Server JSON Data type. SQL Server 2016: Introduced JSON [&#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%2F2017%2F08%2Fsql-server-2016-generate-the-json-formatted-data-from-the-table-data-for-json-auto%2F&amp;linkname=SQL%20Server%202016%3A%20Generate%20the%20JSON%20formatted%20data%20from%20the%20Table%20Data" 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%2F2017%2F08%2Fsql-server-2016-generate-the-json-formatted-data-from-the-table-data-for-json-auto%2F&amp;linkname=SQL%20Server%202016%3A%20Generate%20the%20JSON%20formatted%20data%20from%20the%20Table%20Data" 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%2F2017%2F08%2Fsql-server-2016-generate-the-json-formatted-data-from-the-table-data-for-json-auto%2F&amp;linkname=SQL%20Server%202016%3A%20Generate%20the%20JSON%20formatted%20data%20from%20the%20Table%20Data" 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%2F2017%2F08%2Fsql-server-2016-generate-the-json-formatted-data-from-the-table-data-for-json-auto%2F&amp;linkname=SQL%20Server%202016%3A%20Generate%20the%20JSON%20formatted%20data%20from%20the%20Table%20Data" 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%2F2017%2F08%2Fsql-server-2016-generate-the-json-formatted-data-from-the-table-data-for-json-auto%2F&amp;linkname=SQL%20Server%202016%3A%20Generate%20the%20JSON%20formatted%20data%20from%20the%20Table%20Data" 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%2F2017%2F08%2Fsql-server-2016-generate-the-json-formatted-data-from-the-table-data-for-json-auto%2F&amp;linkname=SQL%20Server%202016%3A%20Generate%20the%20JSON%20formatted%20data%20from%20the%20Table%20Data" 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%2F2017%2F08%2Fsql-server-2016-generate-the-json-formatted-data-from-the-table-data-for-json-auto%2F&#038;title=SQL%20Server%202016%3A%20Generate%20the%20JSON%20formatted%20data%20from%20the%20Table%20Data" data-a2a-url="https://www.dbrnd.com/2017/08/sql-server-2016-generate-the-json-formatted-data-from-the-table-data-for-json-auto/" data-a2a-title="SQL Server 2016: Generate the JSON formatted data from the Table Data"></a></p><p>SQL Server 2016 introduced compelling data type called JSON data type. It also added a variety of new operators and functions related to JSON data type.</p>
<p>This is one of the interesting topics for us, and I have recently published a series of articles on SQL Server JSON Data type.</p>
<blockquote data-secret="NutKpaNf5I" class="wp-embedded-content"><p><a href="https://www.dbrnd.com/2016/12/sql-server-2016-introduced-json-support-to-store-and-retrieve-json-document-isjson-json_value-json_query/">SQL Server 2016: Introduced JSON support, to store and retrieve JSON document</a></p></blockquote>
<p><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2016/12/sql-server-2016-introduced-json-support-to-store-and-retrieve-json-document-isjson-json_value-json_query/embed/#?secret=NutKpaNf5I" data-secret="NutKpaNf5I" width="600" height="338" title="&#8220;SQL Server 2016: Introduced JSON support, to store and retrieve JSON document&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p>In this post, I am sharing one of the relevant queries to convert SQL Server tabular data into JSON formatted data.</p>
<blockquote><p>We are storing JSON formatted data into database and access base on the different filters.</p>
<p>Here, I am sharing one type of utility script to convert your table data into JSON formatted data.<br />
Sometimes it requires populating JSON formatted data for a web service purpose.</p></blockquote>
<p><strong>Create a sample table with data:</strong></p>
<pre class="crayon-plain-tag">CREATE TABLE tbl_Employees
(
	EmpID INT
	,EmpName VARCHAR(10)
	,EmpSalary INT
	,EmpDOJ DATE
)
GO

INSERT INTO tbl_Employees
VALUES
(1,'Anvesh',150000,'2017-01-01')
,(2,'Neevan',125000,'2016-01-01')
,(3,'Martin',90000,'2014-01-01')
,(4,'Roy',175000,'2014-05-08')
,(5,'Maria',60000,'2016-08-10')
,(6,'Jenny',40000,'2016-11-05')
GO</pre> </p>
<p><strong>Use FOR JSON AUTO, and generate the JSON formatted data:</strong></p>
<pre class="crayon-plain-tag">SELECT 
	EmpID
	,EmpName
	,EmpSalary
	,EmpDOJ
FROM tbl_Employees
FOR JSON AUTO</pre> </p>
<p><strong>Result:</strong></p>
<pre class="crayon-plain-tag">[
{"EmpID":1,"EmpName":"Anvesh","EmpSalary":150000,"EmpDOJ":"2017-01-01"}
,{"EmpID":2,"EmpName":"Neevan","EmpSalary":125000,"EmpDOJ":"2016-01-01"}
,{"EmpID":3,"EmpName":"Martin","EmpSalary":90000,"EmpDOJ":"2014-01-01"}
,{"EmpID":4,"EmpName":"Roy","EmpSalary":175000,"EmpDOJ":"2014-05-08"}
,{"EmpID":5,"EmpName":"Maria","EmpSalary":60000,"EmpDOJ":"2016-08-10"}
,{"EmpID":6,"EmpName":"Jenny","EmpSalary":40000,"EmpDOJ":"2016-11-05"}
]</pre> </p>
<p><strong>Use ROOT option, and generate the JSON formatted data:</strong></p>
<pre class="crayon-plain-tag">SELECT 
	EmpID
	,EmpName
	,EmpSalary
	,EmpDOJ
FROM tbl_Employees
FOR JSON PATH, ROOT ('Employee_Root')</pre> </p>
<p><strong>Result:</strong></p>
<pre class="crayon-plain-tag">{"Employee_Root":
	[
	{"EmpID":1,"EmpName":"Anvesh","EmpSalary":150000,"EmpDOJ":"2017-01-01"}
	,{"EmpID":2,"EmpName":"Neevan","EmpSalary":125000,"EmpDOJ":"2016-01-01"}
	,{"EmpID":3,"EmpName":"Martin","EmpSalary":90000,"EmpDOJ":"2014-01-01"}
	,{"EmpID":4,"EmpName":"Roy","EmpSalary":175000,"EmpDOJ":"2014-05-08"}
	,{"EmpID":5,"EmpName":"Maria","EmpSalary":60000,"EmpDOJ":"2016-08-10"}
	,{"EmpID":6,"EmpName":"Jenny","EmpSalary":40000,"EmpDOJ":"2016-11-05"}
	]
}</pre> </p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
