<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-7998687752365941655</atom:id><lastBuildDate>Tue, 10 Sep 2024 12:45:48 +0000</lastBuildDate><category>DAX</category><category>foreign keys in a table</category><category>sql server agent</category><category>Agent_Datetime</category><category>Analytic Window functions sql 2012</category><category>Calendar Table</category><category>Composable DML</category><category>Composable DML SQL 2008</category><category>DATE()</category><category>DATEPART</category><category>DDL triggers</category><category>DENSE RANK</category><category>DISTINCT COUNT</category><category>Data Quality Services</category><category>E notation</category><category>EARLIER example</category><category>FILESTREAM</category><category>FileTable DML</category><category>FileTables</category><category>Filetable last access time</category><category>Filetable schema</category><category>Floating point</category><category>Fuzzy logic 32 bit</category><category>GO</category><category>HalfYear</category><category>Inscope oprator</category><category>Master child table population</category><category>Nth week day</category><category>Order By inside view</category><category>PDF pack reports</category><category>Parse string</category><category>Powerpivot DATE</category><category>Quarter</category><category>READ_COMMITED_SNAPSHOT v/s NOLOCK deadlocks</category><category>Row cannot be located for updating. Some values may have been changed since it was last read</category><category>SQL 2008</category><category>SQL 2012</category><category>SQL 2012 PARTITION BY</category><category>SQL 2012 file access</category><category>SQL Reporting services</category><category>SSIS</category><category>SSIS file processing</category><category>SSRS group reports</category><category>Split delimited string</category><category>Split function</category><category>Sql server agent jobs</category><category>Table Constructor</category><category>UNBOUNDED PRECEDING</category><category>UNPIVOT using VALUES</category><category>VALUES in SQL 2008</category><category>Worker Thread issue</category><category>XML Table populate</category><category>apply operator sql 2008</category><category>batch separator</category><category>business hours</category><category>calculated values</category><category>cascading tables</category><category>column set</category><category>cross apply</category><category>cross db</category><category>cross server</category><category>daily file transfer</category><category>dashboard</category><category>data grouping</category><category>date addition using integer values</category><category>date formats</category><category>date formatting</category><category>date functions</category><category>date values from integer</category><category>datefirst independent date logic</category><category>day comparison</category><category>dependency</category><category>dtexec</category><category>executing packages</category><category>file watcher</category><category>fileTable trigger</category><category>filtered index condition</category><category>filtered indexes query</category><category>get attribute names and values</category><category>get set options of databse in sql 2012</category><category>get sql server service run status</category><category>getFilenamespacepath in trigger</category><category>hextoint</category><category>identity columns</category><category>integer parameters</category><category>iso format</category><category>issues ssis running sql job</category><category>job category</category><category>job history</category><category>job object dependency</category><category>job reference</category><category>locale id</category><category>locale settings</category><category>metadata</category><category>os info</category><category>outer apply</category><category>powerpivot</category><category>provider not supported 64 bit</category><category>python java notation</category><category>quirky update</category><category>recursive deletion</category><category>retrieve filtered indexes</category><category>scientific notation</category><category>script out modules</category><category>script task file watcher</category><category>simulating file watcher</category><category>sp_dboptions SQL 2012</category><category>sp_fkeys</category><category>sp_table_privileges</category><category>sparse column</category><category>sql 2008 object dependency</category><category>sql code deployment</category><category>sql server agent job grouping</category><category>sql_sql_modules</category><category>sqlserver dmv</category><category>sys.dm_server_services</category><category>syscomments</category><category>sysjobs</category><category>table permissions</category><category>table valued parameters</category><category>time difference in hh:mm:ss</category><category>time slot</category><category>win version</category><category>windows language</category><category>xml nodes</category><title>VM Blogs</title><description>Sharing my experiences with SQL programming...</description><link>http://visakhm.blogspot.com/</link><managingEditor>noreply@blogger.com (Visakh Murukesan)</managingEditor><generator>Blogger</generator><openSearch:totalResults>199</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7998687752365941655.post-4396225713974805748</guid><pubDate>Sat, 02 May 2020 21:17:00 +0000</pubDate><atom:updated>2020-05-03T02:47:45.629+05:30</atom:updated><title>Fun with SQL – Find out numbers where adjacent digit differs by 1</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
My friend and mentor Madhivanan had posted an interesting scenario on his blog&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://exploresql.com/2020/05/01/fun-with-sql-find-out-numbers-where-adjacent-digit-differs-by-1/&quot;&gt;https://exploresql.com/2020/05/01/fun-with-sql-find-out-numbers-where-adjacent-digit-differs-by-1/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
and gave it as a challenge for others&lt;br /&gt;
&lt;br /&gt;
The question was below&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcU0mwkHXt69HC83r4_1KDTsCt4gMohalTnMxSo9WLYdJTJ4mTbKlnloZXbSt1KWXrTrWUjwJIZxb_1TR3_KupizIUPWpz1GNTZCUCMpftgy8v55XrgS5_aJqSny1m7NxJ158LgBy_XevE/s1600/qn.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;264&quot; data-original-width=&quot;312&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcU0mwkHXt69HC83r4_1KDTsCt4gMohalTnMxSo9WLYdJTJ4mTbKlnloZXbSt1KWXrTrWUjwJIZxb_1TR3_KupizIUPWpz1GNTZCUCMpftgy8v55XrgS5_aJqSny1m7NxJ158LgBy_XevE/s1600/qn.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
I decided to have a try myself on this&lt;br /&gt;
Here;s my version of the query for the scenario&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;--Provide input value&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;declare @number int&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;set @number=105&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;;With numbers&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;as&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;(&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;select 1 as N UNION ALL&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;SELECT 1 UNION ALL&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;SELECT 1 UNION ALL&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;SELECT 1 UNION ALL&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;SELECT 1 UNION ALL&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;SELECT 1&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;),&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;Num_matrix&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;AS&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;(SELECT ROW_NUMBER() OVER (ORDER BY (SELECT 1))-1 AS Seq&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;FROM numbers n1&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;cross join numbers n2&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;cross join numbers n3&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;cross join numbers n4&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;select m.Seq&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;from&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;(&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;select Seq&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;from num_matrix&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;where seq &amp;lt; @number&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;)m&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;cross join num_matrix n&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;where n.seq between 1 and len(m.Seq)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;group by m.Seq&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;having count(*) = 1&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;or&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;sum(case when abs(substring(cast(m.seq as varchar(100)),n.seq,1)*1 - nullif(substring(cast(m.seq as varchar(100)),n.seq+1,1),&#39;&#39;)*1) = 1&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;or&amp;nbsp; abs(substring(cast(m.seq as varchar(100)),n.seq,1)*1 - nullif(substring(cast(m.seq as varchar(100)),n.seq-1,1),&#39;&#39;)*1) = 1 then 0 else 1 end) = 0&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;order by m.Seq&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
And output is the below&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgi5NbtXo0GMMQuX6GeKV_PjLlEoM6k0_KNOdU6_IbRgfQWb0VWsE7QWUZSGMYPDI1mzU69FOQQgjNzpoAS5hU-DfX6y8bOkaO-jRQc22kupHmjK79qgGAfI3yt_u1ZsigIh1k9LXvSiuER/s1600/op.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;554&quot; data-original-width=&quot;70&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgi5NbtXo0GMMQuX6GeKV_PjLlEoM6k0_KNOdU6_IbRgfQWb0VWsE7QWUZSGMYPDI1mzU69FOQQgjNzpoAS5hU-DfX6y8bOkaO-jRQc22kupHmjK79qgGAfI3yt_u1ZsigIh1k9LXvSiuER/s320/op.png&quot; width=&quot;40&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Try your version and post back the query in comments&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Happy coding!&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</description><link>http://visakhm.blogspot.com/2020/05/my-friend-and-mentor-madhivanan-had.html</link><author>noreply@blogger.com (Visakh Murukesan)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcU0mwkHXt69HC83r4_1KDTsCt4gMohalTnMxSo9WLYdJTJ4mTbKlnloZXbSt1KWXrTrWUjwJIZxb_1TR3_KupizIUPWpz1GNTZCUCMpftgy8v55XrgS5_aJqSny1m7NxJ158LgBy_XevE/s72-c/qn.png" height="72" width="72"/><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7998687752365941655.post-433890377833705021</guid><pubDate>Mon, 03 Feb 2020 06:30:00 +0000</pubDate><atom:updated>2020-02-03T12:00:00.965+05:30</atom:updated><title>SQLServer : Real Time Streaming RDBMS Data Using Apache Kafka Platform</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Problem Statement&amp;nbsp;&lt;/h2&gt;
&lt;div&gt;
There is an application database hosted in a SQLServer instance which is capturing data from a automation software including the readings as well as general health related details of multiple machines.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
The requirement asks for the creation of a close to real time reporting platform which can be used as a monitoring and health check mechanism for the machine as well as perform time series based analysis on it.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Solution&lt;/h2&gt;
&lt;div&gt;
The requirements like above requires the usage of a real time streaming platform which is capable of transmitting huge amount of data close to real time from the database. There are many such streaming platforms available.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
One of the popular streaming tool which can be used in the above case is Apache Kafka. Apache Kafka is capable to connecting to variety of heterogeneous sources and transmit data from them in close to real time as streams.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
So in our above case we make use Kafka to connect to the SQLServer database to extract data from tables and stream them in real time.&lt;/div&gt;
&lt;div&gt;
You can learn more about Kafka from the below link&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;https://kafka.apache.org/intro&quot;&gt;https://kafka.apache.org/intro&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Kafka Connect is an open source component of Kafka which provides the required framework to connect Kafka to a variety of systems to act as source or sink.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;https://docs.confluent.io/current/connect/index.html&quot;&gt;https://docs.confluent.io/current/connect/index.html&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
For connecting to SQL Server we shall make use of either of the below connectors&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
1. JDBC based connector&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;https://docs.confluent.io/current/connect/kafka-connect-jdbc/index.html&quot;&gt;https://docs.confluent.io/current/connect/kafka-connect-jdbc/index.html&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
This connect directly to the tables and extract data from them&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
2. Debezium connector for SQLServer&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;https://debezium.io/documentation/reference/0.9/connectors/sqlserver.html&quot;&gt;https://debezium.io/documentation/reference/0.9/connectors/sqlserver.html&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Debezium is a distributed platform which enables converting RDBMS data to event streams by means of set of source and sink connectors. The connectors enables Kafka Connect to systems as source to extract data and stream them as Kafka topics close to realtime. They also includes sink connectors which enables data from Kafka streams to be stored as data inside RDBMS table.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Illustration&lt;/h2&gt;
&lt;div&gt;
A very detailed step by step illustration for the above scenario is explained in the latest article I&#39;ve contributed to Technet community whose link is given below&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;https://social.technet.microsoft.com/wiki/contents/articles/53589.sql-server-real-time-data-streaming-using-apache-kafka.aspx&quot;&gt;https://social.technet.microsoft.com/wiki/contents/articles/53589.sql-server-real-time-data-streaming-using-apache-kafka.aspx&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
The article explains from setting up of the required systems (SQLServer, Kafka, Kafka Connect, Debezium connector) to streaming data and analyzing the stream through command line and through K-SQL server.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
The article should help someone who is starting on the above mentioned systems and requires implementing use case similar to that specified above&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Wish you happy reading.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
As always feel free to give your valuables feedback&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</description><link>http://visakhm.blogspot.com/2020/02/sqlserver-real-time-streaming-rdbms.html</link><author>noreply@blogger.com (Visakh Murukesan)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7998687752365941655.post-7145309503184322041</guid><pubDate>Thu, 01 Aug 2019 11:31:00 +0000</pubDate><atom:updated>2019-08-01T17:01:49.534+05:30</atom:updated><title>Graph Table Enhancements : Edge Constraints, Utility Functions</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
The second part of the article&amp;nbsp;&lt;a href=&quot;https://visakhm.blogspot.com/2017/05/graph-tables-in-sql-2017.html&quot;&gt;https://visakhm.blogspot.com/2017/05/graph-tables-in-sql-2017.html&lt;/a&gt;&amp;nbsp;can be found here&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://social.technet.microsoft.com/wiki/contents/articles/53162.graph-table-enhancements-edge-constraints-system-utility-functions.aspx&quot;&gt;https://social.technet.microsoft.com/wiki/contents/articles/53162.graph-table-enhancements-edge-constraints-system-utility-functions.aspx&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Here I have explained on the concept of &lt;b&gt;Edge Constraints &lt;/b&gt;and how they can be used to enforce the relationships between Node tables within an Edge table.&lt;br /&gt;
&lt;br /&gt;The article also explains on certain system functions which can be used in conjunction with Node and Edge tables to extract the information from pseudo columns in Graph tables which can be utilized in the filter conditions of queries.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</description><link>http://visakhm.blogspot.com/2019/08/graph-table-enhancements-edge.html</link><author>noreply@blogger.com (Visakh Murukesan)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7998687752365941655.post-2691550266949278428</guid><pubDate>Wed, 10 Apr 2019 05:19:00 +0000</pubDate><atom:updated>2019-04-10T10:49:08.475+05:30</atom:updated><title>T-SQL Tips: Generating Nested XML Structures Efficiently Using FLOWR Expressions</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Introduction&lt;/h2&gt;
&lt;div&gt;
I have been thinking about publishing an article on this for quite a while now. Of late have been too busy (or may be lazy is a better word!) to write on this. Finally thought of breaking the&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
Previously I had blogged about how FOR XML PATH can be used to generate nested XML structures in the below two articles&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;https://visakhm.blogspot.com/2014/05/t-sql-tips-fun-with-for-xml-path.html&quot;&gt;https://visakhm.blogspot.com/2014/05/t-sql-tips-fun-with-for-xml-path.html&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;https://visakhm.blogspot.com/2013/12/generating-nested-xml-structures-with.html&quot;&gt;https://visakhm.blogspot.com/2013/12/generating-nested-xml-structures-with.html&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
There is an alternate method that can be used to generate these nested XML structures using FLOWR expressions. This will be much more efficient than using nested subqueries for large data volumes.&lt;/div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;Illustration&lt;/h2&gt;
&lt;div&gt;
Using the same example as in the previous article, we can see how FLOWR expression can be applied to get same result&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;CREATE TABLE [dbo].[Orders](&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;[OrderID] [int] IDENTITY(1,1) NOT NULL,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;[CustName] [varchar](100) NULL,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;[OrderDate] [date] NULL,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;[ReferredBy] [varchar](100) NULL,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;[AgentGrp] [varchar](30) NULL,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;PRIMARY KEY CLUSTERED&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;(&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;[OrderID] ASC&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;)WITH (PAD_INDEX&amp;nbsp; = OFF, STATISTICS_NORECOMPUTE&amp;nbsp; = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS&amp;nbsp; = ON, ALLOW_PAGE_LOCKS&amp;nbsp; = ON) ON [PRIMARY]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;) ON [PRIMARY]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;GO&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;SET ANSI_PADDING OFF&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;GO&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;SET IDENTITY_INSERT [dbo].[Orders] ON&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;INSERT [dbo].[Orders] ([OrderID], [CustName], [OrderDate], [ReferredBy], [AgentGrp]) VALUES (1, N&#39;ABC Corp&#39;, CAST(0xB8350B00 AS Date), N&#39;Agent 1&#39;, N&#39;110&#39;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;INSERT [dbo].[Orders] ([OrderID], [CustName], [OrderDate], [ReferredBy], [AgentGrp]) VALUES (12353, N&#39;R &amp;amp; K Associates&#39;, CAST(0x7A370B00 AS Date), N&#39;Agent 5&#39;, N&#39;105&#39;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;INSERT [dbo].[Orders] ([OrderID], [CustName], [OrderDate], [ReferredBy], [AgentGrp]) VALUES (13345, N&#39;Zyng Enterprises&#39;, CAST(0x5D370B00 AS Date), N&#39;Agent 3&#39;, N&#39;110&#39;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;INSERT [dbo].[Orders] ([OrderID], [CustName], [OrderDate], [ReferredBy], [AgentGrp]) VALUES (15789, N&#39;Maxim Bailey&#39;, CAST(0x7A370B00 AS Date), N&#39;Agent 1&#39;, N&#39;120&#39;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;INSERT [dbo].[Orders] ([OrderID], [CustName], [OrderDate], [ReferredBy], [AgentGrp]) VALUES (22345, N&#39;Kyzer&#39;, CAST(0xA5370B00 AS Date), N&#39;Agent 2&#39;, N&#39;120&#39;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;INSERT [dbo].[Orders] ([OrderID], [CustName], [OrderDate], [ReferredBy], [AgentGrp]) VALUES (29398, N&#39;ABC Corp&#39;, CAST(0x54370B00 AS Date), N&#39;Agent 4&#39;, N&#39;105&#39;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;SET IDENTITY_INSERT [dbo].[Orders] OFF&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;GO&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3yibGJi3ezLLagrKk-dT9d7RLPGdVFyUPKffpzX7Ej9KOpfJi-xVbGfMFla025c1muIEMti1SvPhCg2ILYiGIRkrokYI2Jn8VDYegt5zL6xD547MHxUGJObovzLM15J-duXxPc_OE9F6S/s1600/ss.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;474&quot; data-original-width=&quot;710&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3yibGJi3ezLLagrKk-dT9d7RLPGdVFyUPKffpzX7Ej9KOpfJi-xVbGfMFla025c1muIEMti1SvPhCg2ILYiGIRkrokYI2Jn8VDYegt5zL6xD547MHxUGJObovzLM15J-duXxPc_OE9F6S/s1600/ss.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div style=&quot;color: blue;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
The result will be as below&lt;/div&gt;
&lt;div style=&quot;color: blue;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjD3tuisu4x5rDFQ0wq1B3VmGzQ5FovsEGn1emvwVnBg_6_SnrjWciIbniFEK48zoo0384F7ls6-9_JSs1X5WAMoJeasqzGynlU9GA8_o9IwkCB7YeOEcci5l_9_sRMJD1v_A8Z1Ji5-G31/s1600/ss.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1600&quot; data-original-width=&quot;552&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjD3tuisu4x5rDFQ0wq1B3VmGzQ5FovsEGn1emvwVnBg_6_SnrjWciIbniFEK48zoo0384F7ls6-9_JSs1X5WAMoJeasqzGynlU9GA8_o9IwkCB7YeOEcci5l_9_sRMJD1v_A8Z1Ji5-G31/s1600/ss.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
As seen from result above the FLOWR expression helps us in building the XML in the structure we want.&lt;/div&gt;
&lt;div&gt;
The first part of the query using FOR XML will built a simple XML structure with all attributes involved. Then we apply query function on top of the simple XML we built and use FLOWR expressions inside to get XML to the format we desire&lt;br /&gt;&lt;br /&gt;Another illustration is given below&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;declare @catalog table&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;(&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;catalogid int identity(1001,1),&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;catalogdescription nvarchar(100),&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;catalogcreationdate datetime&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;insert @catalog (catalogdescription,catalogcreationdate)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;values&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;(N&#39;mens wear&#39;,getdate()-120),&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;(N&#39;womens wear&#39;,getdate()-35),&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;(N&#39;sports wear&#39;,getdate()-90),&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;(N&#39;accessories&#39;,getdate()-25),&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;(N&#39;Beauté&#39;,getdate()-20)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;declare @products table&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;(&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;ProductID&amp;nbsp; int identity(10001,1),&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;ProductDesc nvarchar(100),&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;CatalogID int&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;insert @products (ProductDesc,CatalogID)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;values (&#39;Crop Tops&#39;,1002),&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;(&#39;Sweat Shirts&#39;,1002),&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;(&#39;Bodyfit Jeans&#39;,1001),&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;(&#39;Golden Perfurme&#39;,1005),&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;(&#39;Jerseys&#39;,1003),&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;(&#39;Pendant with Earstuds&#39;,1004),&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;(&#39;Anklet&#39;,1004),&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;(&#39;Shorts&#39;,1001)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;declare @productattributeTypes table&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;(&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;AttributeTypeID int identity(10001,1),&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;AttributeTypeDesc&amp;nbsp; nvarchar(100)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;insert @productattributeTypes (AttributeTypeDesc)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;values (&#39;Shoe Size&#39;),(&#39;Belt Size&#39;),(&#39;Base Material&#39;),(&#39;Color&#39;),(&#39;Pattern&#39;),(&#39;Size&#39;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;declare @productattributevalues table&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;(&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;AttributeID int identity(10001,1),&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;ProductID&amp;nbsp; int ,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;AttributeTypeID int,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;AttributeValue nvarchar(100)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;insert @productattributevalues (AttributeTypeID,ProductID,AttributeValue)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;values (10003,10001,&#39;Cotton&#39;),&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;(10003,10002,&#39;Polyester&#39;),&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;(10006,10002,&#39;XL&#39;),&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;(10006,10003,&#39;32&#39;),&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;(10005,10003,&#39;Slim fit&#39;),&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;(10003,10004,&#39;Cologne&#39;),&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;(10006,10004,&#39;100 ml&#39;),&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;(10003,10005,&#39;Polyester&#39;),&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;(10003,10006,&#39;Black Metal&#39;),&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;(10003,10007,&#39;White metal with stones&#39;),&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;(10006,10008,&#39;Cotton&#39;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
Here&#39;s the query&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBFH2Kn35hCLf_HIHro4W1YqHKxJBsakKA6Fy9liSZz_gdwnx6so51K1LSwmIfgnhySzEYz2RZiZeHN-cGySedIgVJDwCN2Y9P3JzKN-g1ABZRzbD5taW_5TH1cq6DA6CHlwq4N3WW7w5d/s1600/ss.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;507&quot; data-original-width=&quot;940&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBFH2Kn35hCLf_HIHro4W1YqHKxJBsakKA6Fy9liSZz_gdwnx6so51K1LSwmIfgnhySzEYz2RZiZeHN-cGySedIgVJDwCN2Y9P3JzKN-g1ABZRzbD5taW_5TH1cq6DA6CHlwq4N3WW7w5d/s1600/ss.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
with the result as below&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg01OAMdXLR7TxhAjJlu4-FHbZjh6eP2ikKmsNzD-wYUtkta0Kg5sRTWUjmLG-7EdnCLY_3_DGtyZZwmABaQNaBEcq-JYXP1cbGdFO4NcnuutQsBK5sAH9RsngUzCUS8tJkbujsFncozmY7/s1600/ss.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1600&quot; data-original-width=&quot;689&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg01OAMdXLR7TxhAjJlu4-FHbZjh6eP2ikKmsNzD-wYUtkta0Kg5sRTWUjmLG-7EdnCLY_3_DGtyZZwmABaQNaBEcq-JYXP1cbGdFO4NcnuutQsBK5sAH9RsngUzCUS8tJkbujsFncozmY7/s1600/ss.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Conclusion&lt;/h2&gt;
&lt;/div&gt;
&lt;div&gt;
From the two illustrations above, its evident that FLOWR expression based method can be used effectively to generate nested XML structures&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Artifacts&lt;/h2&gt;
&lt;div&gt;
The full code for generating the XML structures can be found below&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;https://drive.google.com/file/d/1lUEv_6O5IgZJtQZgsH2odBzz9zW-kBit/view?usp=sharing&quot;&gt;https://drive.google.com/file/d/1lUEv_6O5IgZJtQZgsH2odBzz9zW-kBit/view?usp=sharing&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;https://drive.google.com/file/d/17ugVWgTR9irRzeuf6ifHgzxz4GKxz_xH/view?usp=sharing&quot;&gt;https://drive.google.com/file/d/17ugVWgTR9irRzeuf6ifHgzxz4GKxz_xH/view?usp=sharing&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</description><link>http://visakhm.blogspot.com/2019/04/t-sql-tips-generating-nested-xml.html</link><author>noreply@blogger.com (Visakh Murukesan)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3yibGJi3ezLLagrKk-dT9d7RLPGdVFyUPKffpzX7Ej9KOpfJi-xVbGfMFla025c1muIEMti1SvPhCg2ILYiGIRkrokYI2Jn8VDYegt5zL6xD547MHxUGJObovzLM15J-duXxPc_OE9F6S/s72-c/ss.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7998687752365941655.post-8514173782637359300</guid><pubDate>Mon, 29 Oct 2018 07:36:00 +0000</pubDate><atom:updated>2018-10-29T13:07:06.676+05:30</atom:updated><title>SQL Tips: String Or Binary Data Truncated Error Message Enhancement</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Introduction&lt;/h2&gt;
&lt;div&gt;
I&#39;m sure lots of us who have been developing in SQLServer over ages would agree to the fact that the error &lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;pre class=&quot;csharpcode&quot; style=&quot;background-color: whitesmoke; border-radius: 4px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13px; line-height: 1.42857; margin-bottom: 10px; overflow-wrap: break-word; overflow: auto; padding: 9.5px; word-break: break-all;&quot;&gt;&lt;span style=&quot;color: red;&quot;&gt;String &lt;span class=&quot;kwrd&quot; style=&quot;box-sizing: border-box;&quot;&gt;or&lt;/span&gt; &lt;span class=&quot;kwrd&quot; style=&quot;box-sizing: border-box;&quot;&gt;binary&lt;/span&gt; &lt;span class=&quot;kwrd&quot; style=&quot;box-sizing: border-box;&quot;&gt;data&lt;/span&gt; would be truncated.
The &lt;span class=&quot;kwrd&quot; style=&quot;box-sizing: border-box;&quot;&gt;statement&lt;/span&gt; has been terminated.&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
is one of the most frustrating errors you would have ever come across in T-SQL. Especially in case of long stored procedures with lengthy INSERT...SELECT statements it was always a daunting to task to find the column which acted as the root cause for the above error. And most times the error happens at a later stage due to absence of any breaking data at the time of implementation.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
A good majority of senior developers have always complained against this ambiguity and multiple connect items were logged for this issue which got pretty good support as well.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Implementation&lt;/h2&gt;
&lt;div&gt;
When feedback platform was moved to &lt;a href=&quot;http://feedback.azure.com/&quot;&gt;feedback.azure.com&lt;/a&gt;&amp;nbsp; Microsoft had opened a request in that for the connect requests and this had also got good number of votes&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;https://feedback.azure.com/forums/908035-sql-server/suggestions/32909539-string-or-binary-data-would-be-truncated&quot;&gt;https://feedback.azure.com/forums/908035-sql-server/suggestions/32909539-string-or-binary-data-would-be-truncated&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Accordingly MS started background work to fix this and finally the fix was released in SQL 2019 version to enhance the error message to include more information. Based on this, the error message has been modified to the below&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;pre class=&quot;csharpcode&quot; style=&quot;background-color: whitesmoke; border-radius: 4px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13px; line-height: 1.42857; margin-bottom: 10px; overflow-wrap: break-word; overflow: auto; padding: 9.5px; word-break: break-all;&quot;&gt;&lt;span style=&quot;color: red;&quot;&gt;String &lt;span class=&quot;kwrd&quot; style=&quot;box-sizing: border-box;&quot;&gt;or&lt;/span&gt; &lt;span class=&quot;kwrd&quot; style=&quot;box-sizing: border-box;&quot;&gt;binary&lt;/span&gt; &lt;span class=&quot;kwrd&quot; style=&quot;box-sizing: border-box;&quot;&gt;data&lt;/span&gt; would be truncated &lt;span class=&quot;kwrd&quot; style=&quot;box-sizing: border-box;&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;kwrd&quot; style=&quot;box-sizing: border-box;&quot;&gt;table&lt;/span&gt; &lt;span class=&quot;str&quot; style=&quot;box-sizing: border-box;&quot;&gt;&#39;XXXXXXXXXX&#39;&lt;/span&gt;, &lt;span class=&quot;kwrd&quot; style=&quot;box-sizing: border-box;&quot;&gt;column&lt;/span&gt; &lt;span class=&quot;str&quot; style=&quot;box-sizing: border-box;&quot;&gt;&#39;YYYYYYY&#39;&lt;/span&gt;. Truncated &lt;span class=&quot;kwrd&quot; style=&quot;box-sizing: border-box;&quot;&gt;value&lt;/span&gt;: &lt;span class=&quot;str&quot; style=&quot;box-sizing: border-box;&quot;&gt;&#39;ZZZZZZ&#39;&lt;/span&gt;.
The &lt;span class=&quot;kwrd&quot; style=&quot;box-sizing: border-box;&quot;&gt;statement&lt;/span&gt; has been terminated.&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
This was really a good news for all of us, but still there was a small concern that we have wait a while to see this in action as most of the currently implemented instances were on SQL 2016 and SQL 2017.&lt;/div&gt;
&lt;div&gt;
But it seems MS read our mind on this and now I&#39;m really happy to see the announcement that this enhancement has been backported to SQL 2017 CU 12 and on SQL 2016 SP2 CU.&lt;/div&gt;
&lt;div&gt;
To enable this currently a trace flag has also being introduced (&lt;b&gt;trace flag 460) &lt;/b&gt;which can be enabled at session level or at server level itself. Once set it replaces the older error message with the new one above for truncation exceptions raised. The future SQL 2019 releases should have this message as the default and wont require setting the trace flag explicitly for this.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Illustration&lt;/h2&gt;
&lt;div&gt;
Lets see an illustration of the above error message on a sample table&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
The code will look like below&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;--setting the trace flag for the session&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;DBCC TRACEON&amp;nbsp; (460);&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;GO&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;--sample table&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;declare @t table(&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;v varchar(10)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;-- insert values&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;insert @t&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;values&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;(&#39;test&#39;),&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;(&#39;this is a long value to check for truncation error&#39;) -- this raises the error&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
Now lets check the result&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAVEHHbZ9TmaSoAwequrBkZvo5P27mJRvePuOwVRojH9NwZBuGfbs5N7GjiQS3JNjcXiUHzYsrwhjQlVQryboiBwF7I-I6X51n_ZXdLT7mH2UXnTXK9mn3jZKn2ZBi-dVfpc0T_cdHEhY7/s1600/SSMS.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;518&quot; data-original-width=&quot;1083&quot; height=&quot;305&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAVEHHbZ9TmaSoAwequrBkZvo5P27mJRvePuOwVRojH9NwZBuGfbs5N7GjiQS3JNjcXiUHzYsrwhjQlVQryboiBwF7I-I6X51n_ZXdLT7mH2UXnTXK9mn3jZKn2ZBi-dVfpc0T_cdHEhY7/s640/SSMS.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
As expected we will get the&amp;nbsp; new error message which gives clear indication of the table, column and value which caused the truncation exception. This makes it much easier for someone to debug and fix the issue.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Now if you turn off the trace flag and try, you can see that it reverts to the old error message&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXUXF5kbUrRm2oEX2zBCZA7Tok9oftMh0YY-RIw9ofuaOES_gqOGEtis-Sr9Z7IHQEPqtDBcvBEv8FWIMWYLE7368ZJlwgFu-YNPY_U8WxuTByryZCQaxvNgiO19lDcRn9-tb5KlCDOuwL/s1600/SSMS.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;536&quot; data-original-width=&quot;863&quot; height=&quot;396&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXUXF5kbUrRm2oEX2zBCZA7Tok9oftMh0YY-RIw9ofuaOES_gqOGEtis-Sr9Z7IHQEPqtDBcvBEv8FWIMWYLE7368ZJlwgFu-YNPY_U8WxuTByryZCQaxvNgiO19lDcRn9-tb5KlCDOuwL/s640/SSMS.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Conclusion&lt;/h2&gt;
&lt;div&gt;
As seen from the above illustration, this new enhancement on truncation error is really a life saver for someone developing or debugging Transact SQL code and is sure to save many hours of development effort on truncation issues which is one of the high frequent issues we come across in ETL, datawarehousing projects.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
The official announcement regarding the release can be found in the below link&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;https://blogs.msdn.microsoft.com/sql_server_team/string-or-binary-data-would-be-truncated-replacing-the-infamous-error-8152/&quot;&gt;https://blogs.msdn.microsoft.com/sql_server_team/string-or-binary-data-would-be-truncated-replacing-the-infamous-error-8152/&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Let me end this article by conveying big thanks to &lt;span style=&quot;background-color: white; color: #333333; font-family: &amp;quot;segoe ui&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;arial&amp;quot; , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif; font-size: 14px;&quot;&gt;Pedro Lopes (&lt;/span&gt;&lt;a href=&quot;https://twitter.com/SQLPedro&quot; style=&quot;background-color: white; box-sizing: border-box; color: #337ab7; font-family: &amp;quot;Segoe UI&amp;quot;, Tahoma, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 14px; text-decoration-line: none;&quot;&gt;@SQLPedro&lt;/a&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &amp;quot;segoe ui&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;arial&amp;quot; , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif; font-size: 14px;&quot;&gt;) – Senior Program Manager&lt;/span&gt;&amp;nbsp;and the entire MS team for the help and support provided in addressing this issue and coming up with the release.&lt;/div&gt;
&lt;/div&gt;
</description><link>http://visakhm.blogspot.com/2018/10/sql-tips-string-or-binary-data.html</link><author>noreply@blogger.com (Visakh Murukesan)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAVEHHbZ9TmaSoAwequrBkZvo5P27mJRvePuOwVRojH9NwZBuGfbs5N7GjiQS3JNjcXiUHzYsrwhjQlVQryboiBwF7I-I6X51n_ZXdLT7mH2UXnTXK9mn3jZKn2ZBi-dVfpc0T_cdHEhY7/s72-c/SSMS.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7998687752365941655.post-6996464113887315713</guid><pubDate>Tue, 16 Oct 2018 08:12:00 +0000</pubDate><atom:updated>2018-10-16T13:42:06.005+05:30</atom:updated><title>SQL Agent Tips: Using JOBID Token in T-SQL Job Steps To Fetch The Job GUID</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Introduction&lt;/h2&gt;
One of the pretty cool features available in SQL Server Agent is the ability to use tokens for returning values for many system parameters at runtime (for example Server Name, Job Name, Database Name etc).&lt;br /&gt;
Recently there was an issue reported in the forums regarding the usage of JOBID token for getting the details of job within job step. This prompted me to analyse more on the feature.&lt;br /&gt;
This article explains how you can use the JOBID token to return the job identifier information inside the job step&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Illustration&lt;/h2&gt;
There are quite a few scenarios where we need to use job related information in scripts inside SQL Agent job steps. There are tokens available for this purpose which can be used to return data from job metadata. &lt;br /&gt;One of common use case is when we need to capture the job id for logging purpose inside a step within the same job.&lt;br /&gt;
The code can be given as below&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;DECLARE @jobID varchar(100)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;SET @jobID = &#39;$(ESCAPE_SQUOTE(JOBID))&#39;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;EXEC [dbo].[notifyjobfailure]&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; @jobID&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
The notifyjobfailure procedure looks like this&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;CREATE proc&amp;nbsp; [dbo].[notifyjobfailure]&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;@jobid varchar(100)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;as&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;insert jobnotify(jobname)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;select @jobid&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
Where jobnotify is a simple table&amp;nbsp; for capturing the job_id along with the current system time.&lt;br /&gt;
&lt;br /&gt;
Include this within step of a job and try executing it. We will find that the job step will fail like below&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgS04urqNTsUtGJj_1fXbUFhLZgODUQTYNhspDUbPGI_cLu-lfYjd1oO9p8EAto17MAo3zPIqpMr7EbexCgUXh9Sxu_sEtu1USLR-lzox2YHSDqxlkoUbFpMBNcIC5wakWqwNK8DtJ-wtij/s1600/SSMS.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;559&quot; data-original-width=&quot;933&quot; height=&quot;380&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgS04urqNTsUtGJj_1fXbUFhLZgODUQTYNhspDUbPGI_cLu-lfYjd1oO9p8EAto17MAo3zPIqpMr7EbexCgUXh9Sxu_sEtu1USLR-lzox2YHSDqxlkoUbFpMBNcIC5wakWqwNK8DtJ-wtij/s640/SSMS.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
As seen from the image above, we get a conversion error trying to use the token inside job step.&lt;br /&gt;
&lt;br /&gt;
To understand why this is happening I tweaked the datatype of the column within the table and the parameter to be of type varchar.&lt;br /&gt;
&lt;br /&gt;
So modified code will look like this&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;ALTER proc&amp;nbsp; [dbo].[notifyjobfailure]&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;@jobid varchar(100)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;as&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;insert jobnotify(jobname)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;select @jobid&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
Try executing the job and we can see that it executes fine now.&lt;br /&gt;
Check the table and we can see the below data populated&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgBnp9DuQXt5VpWY3JCVa_4GyIw2NmZf1R281nAYu_M8meMblmAE4yN9NDw8RLp5AchFEbgoQhAvWWfnEty1TCBeepTsCOx0SbG9aEqoOz69IKOuITVAlo7PKJdaNqM45mquReqFpp_pLnU/s1600/SSMS.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;141&quot; data-original-width=&quot;538&quot; height=&quot;164&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgBnp9DuQXt5VpWY3JCVa_4GyIw2NmZf1R281nAYu_M8meMblmAE4yN9NDw8RLp5AchFEbgoQhAvWWfnEty1TCBeepTsCOx0SbG9aEqoOz69IKOuITVAlo7PKJdaNqM45mquReqFpp_pLnU/s640/SSMS.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Checking the data we can see that the token value gets passed in hexadecimal format rather than as a GUID.&lt;br /&gt;
Taking this into consideration, we can tweak the code again to add a conversion step to ensure value gets passed as a valid unique identifier (GUID). Accordingly, the code will look like this&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;

&lt;span style=&quot;color: blue;&quot;&gt;DECLARE @jobID uniqueidentifier&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;SET @jobID = CONVERT(uniqueidentifier,$(ESCAPE_SQUOTE(JOBID)))&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;EXEC [dbo].[notifyjobfailure]&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; @jobID&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;The procedure code will also be modified as below&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;CREATE proc&amp;nbsp; [dbo].[notifyjobfailure]&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;@jobid uniqueidentifier&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;as&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;insert jobnotify(jobname)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;select @jobid&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;GO&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
Now go ahead and execute the job and you will find that it executes successfully&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Conclusion&lt;/h2&gt;
Based on the illustration above we can understand the below points&lt;br /&gt;
&lt;br /&gt;
1. The value for JOBID token gets passed as a hexadecimal value&lt;br /&gt;
2. While trying to save the value to a table column of type uniqueidentifier always make sure we do an explicit conversion. Otherwise the code will break as seen from the illustration&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</description><link>http://visakhm.blogspot.com/2018/10/sql-agent-tips-using-jobid-token-in-t.html</link><author>noreply@blogger.com (Visakh Murukesan)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgS04urqNTsUtGJj_1fXbUFhLZgODUQTYNhspDUbPGI_cLu-lfYjd1oO9p8EAto17MAo3zPIqpMr7EbexCgUXh9Sxu_sEtu1USLR-lzox2YHSDqxlkoUbFpMBNcIC5wakWqwNK8DtJ-wtij/s72-c/SSMS.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7998687752365941655.post-5592778813513066174</guid><pubDate>Tue, 14 Aug 2018 07:29:00 +0000</pubDate><atom:updated>2018-08-30T21:29:04.403+05:30</atom:updated><title>SSIS Tips: Enforcing TLS 1.2 For SSIS 2012 Connections</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;Impetus&lt;/b&gt;&lt;/h2&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
The main inspiration behind this article comes from a recent issue faced in one of my projects for configuring TLS 1.2 based connectivity to a HTTP endpoint and steps taken in resolving the same&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;Scenario&lt;/b&gt;&lt;/h2&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
In one of the projects, there was a SQL Agent job which started suddenly failing. There was no changes done on any of the core functionality so it was evident that the failure had something to do with some changes done at the destination end.The failure was attributed to a task which was utilizing a HTTP connection manager to connect to a URL for downloading response in&amp;nbsp; XML format.&lt;br /&gt;
&lt;br /&gt;
The failure message looked like below in the SQL Agent history&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhflHUdmEgv8yx5VAsTjV07ZItxannPRjYTBALbDVEJC7EwsfohiQlz_fIjXEP1JhgSHti6DUHqzZrD0j9TgED_yxAOrzpySYIjT-nqjcj-_erlmfmVXOTvIGprgQrXQ6a4oRbseBUJ4vds/s1600/ss.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;76&quot; data-original-width=&quot;1600&quot; height=&quot;30&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhflHUdmEgv8yx5VAsTjV07ZItxannPRjYTBALbDVEJC7EwsfohiQlz_fIjXEP1JhgSHti6DUHqzZrD0j9TgED_yxAOrzpySYIjT-nqjcj-_erlmfmVXOTvIGprgQrXQ6a4oRbseBUJ4vds/s640/ss.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
i.e.&lt;br /&gt;
&amp;nbsp;&lt;span style=&quot;color: red;&quot;&gt;&lt;i&gt;Error: The underlying connection was closed: An unexpected error occurred on a send.&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;&lt;i&gt;&amp;nbsp; Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;&lt;i&gt;&amp;nbsp; &amp;nbsp; An existing connection was forcibly closed by the remote host&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
On analysis and checking with the admin team, we came to know that they enabled TLS 1.2 on the server endpoint. This was causing the connection to fail as the SQLServer we had was on 2012 version and it was still using TLS 1.0 based connection.&lt;br /&gt;
&lt;br /&gt;
The challenge was to see how this can be sorted out. This article discusses a quick solution which can be applied in scenarios like above to ensure successful connection&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Solution&lt;/h2&gt;
&lt;div&gt;
The solution involves forcing the connection to use TLS 1.2 this can be done by using the below single line of code inside a script task in your SSIS package.&lt;br /&gt;
&lt;br /&gt;
This should be the first task inside the package and will have single line code as shown below&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; System.Net.ServicePointManager.SecurityProtocol = (System.Net.SecurityProtocolType)3072;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
Here&#39;s how code looks inside the Script Task&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOyqFHLYvD1YjfJhYzXE5Ve5vrFcNPhGcUvFgUuAbBfcn0H6bARwqEvNAnisOn0ODZ9GiGcokqOpM6cA8gBxapSTRSmoxL2SrZ1vVqg78lbxmXi3quSPGs_ZSZgvYMeqJwD9VYN33K4Tit/s1600/SSIS.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;463&quot; data-original-width=&quot;1085&quot; height=&quot;272&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOyqFHLYvD1YjfJhYzXE5Ve5vrFcNPhGcUvFgUuAbBfcn0H6bARwqEvNAnisOn0ODZ9GiGcokqOpM6cA8gBxapSTRSmoxL2SrZ1vVqg78lbxmXi3quSPGs_ZSZgvYMeqJwD9VYN33K4Tit/s640/SSIS.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
3072 corresponds to TLS 1.2 protocol in the SecurityProtocolType enumeration within System.Net namespace&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;default prettyprint prettyprinted&quot; style=&quot;background-color: #eff0f1; border: 0px; box-sizing: inherit; color: #393318; font-family: Consolas, Menlo, Monaco, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace, sans-serif; font-size: 13px; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 1em; max-height: 600px; overflow: auto; padding: 5px; vertical-align: baseline; width: auto; word-wrap: normal;&quot;&gt;&lt;code style=&quot;border: 0px; box-sizing: inherit; font-family: Consolas, Menlo, Monaco, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace, sans-serif; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: inherit;&quot;&gt;&lt;span class=&quot;kwd&quot; style=&quot;border: 0px; box-sizing: inherit; color: #101094; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;namespace&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;border: 0px; box-sizing: inherit; color: #2b91af; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;border: 0px; box-sizing: inherit; color: #2b91af; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Net&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;border: 0px; box-sizing: inherit; color: #2b91af; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;border: 0px; box-sizing: inherit; color: #2b91af; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Flags&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;border: 0px; box-sizing: inherit; color: #101094; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;public&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;border: 0px; box-sizing: inherit; color: #101094; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;enum&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;border: 0px; box-sizing: inherit; color: #2b91af; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;SecurityProtocolType&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
       &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;border: 0px; box-sizing: inherit; color: #2b91af; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Ssl3&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;border: 0px; box-sizing: inherit; color: #7d2727; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;48&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
       &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;border: 0px; box-sizing: inherit; color: #2b91af; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Tls&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;border: 0px; box-sizing: inherit; color: #7d2727; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;192&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
       &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;border: 0px; box-sizing: inherit; color: #2b91af; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Tls11&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;border: 0px; box-sizing: inherit; color: #7d2727; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;768&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
       &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;border: 0px; box-sizing: inherit; color: #2b91af; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Tls12&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;border: 0px; box-sizing: inherit; color: #7d2727; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;3072&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
And you need to have .Net framework 4.5 installed to get this work correctly.&lt;br /&gt;
&lt;br /&gt;
Once this is done it enforces TLS 1.2 for the connection following and connections would be successful.&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Conclusion&lt;/h2&gt;
&lt;/div&gt;
&lt;div&gt;
As shown above this method can be used in SSIS 2012 to ensure TLS 1.2 protocol is enforced for connecting to a client app which is using enhanced encryption&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</description><link>http://visakhm.blogspot.com/2018/08/ssis-tips-enforcing-tls-12-for-ssis.html</link><author>noreply@blogger.com (Visakh Murukesan)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhflHUdmEgv8yx5VAsTjV07ZItxannPRjYTBALbDVEJC7EwsfohiQlz_fIjXEP1JhgSHti6DUHqzZrD0j9TgED_yxAOrzpySYIjT-nqjcj-_erlmfmVXOTvIGprgQrXQ6a4oRbseBUJ4vds/s72-c/ss.png" height="72" width="72"/><thr:total>3</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7998687752365941655.post-6229858836802411175</guid><pubDate>Mon, 19 Feb 2018 08:13:00 +0000</pubDate><atom:updated>2018-02-19T13:43:52.218+05:30</atom:updated><title>SSRS 2017 Tips: Solving Default Font Issue in SSDT 15.5 Preview</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Impetus&amp;nbsp;&lt;/h2&gt;
&lt;div&gt;
The impetus for writing this article came from a recent question which was asked in one of the forums.&lt;/div&gt;
&lt;div&gt;
This was regarding the creation of SSRS report using VS 2017 shell based SQLServer Data Tools. There was a post which indicated that preview tab of the SSDT 2017 causes some tablix data to disappear.&lt;br /&gt;
This article discusses on the root cause behind the issue and a workaround you shall use to avoid the issue.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Illustration&lt;/h2&gt;
&lt;/div&gt;
&lt;div&gt;
Consider the below sample report for this example which shows some addresses&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5gInO9FLXaY6Taaks4EyCbsLAg-GmI0kc6yyWc6wOGeWuK0YxEFs-x_LEJUBu5EYXPlqbsC5p9vjKXdwxzKY_XEdjUUqB5F3pk1xMKK0fhaSR9P8Sn8-RRjcdeIOR4w_ymcLabJ_hgM2w/s1600/ss.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;642&quot; data-original-width=&quot;464&quot; height=&quot;640&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5gInO9FLXaY6Taaks4EyCbsLAg-GmI0kc6yyWc6wOGeWuK0YxEFs-x_LEJUBu5EYXPlqbsC5p9vjKXdwxzKY_XEdjUUqB5F3pk1xMKK0fhaSR9P8Sn8-RRjcdeIOR4w_ymcLabJ_hgM2w/s640/ss.png&quot; width=&quot;460&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Now lets try using this data inside a report.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
The source query is below&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;select SUBSTRING(LTRIM(RTRIM(DestAddr4)),1,2) as Post,DestAddr1,DestAddr4,TransportTelNo from dbo.SvrDestinations&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;WHERE DestAddr4 is not null&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;and LEN(LTRIM(RTRIM(DestAddr4))) &amp;gt; 2&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;ORDER BY DestAddr4&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Using this in a table will look like this&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgGSb8gIwKpanJ7y8xdLw_sY_AxjiLfcFcActmK630LxgTFbF1VxUWMmDBl77seTlnrqOqkTZkLZXvvNMaxs-YGXRkm2nZzyDQM1QDPH_ge8RZBronEnFjAl4W11q63VxEL0tYsamoqZ1F/s1600/SSRSConfig.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;150&quot; data-original-width=&quot;1167&quot; height=&quot;81&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgGSb8gIwKpanJ7y8xdLw_sY_AxjiLfcFcActmK630LxgTFbF1VxUWMmDBl77seTlnrqOqkTZkLZXvvNMaxs-YGXRkm2nZzyDQM1QDPH_ge8RZBronEnFjAl4W11q63VxEL0tYsamoqZ1F/s640/SSRSConfig.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
Now go to the preview tab to check the report preview and we can see this&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPWRyVyhx-cZoR6I9tFUzZXW8gbX5u8s4y3Rxf52_bhGMXPmmoMdGUl4tYXGMgeKOL4t_YpeBWVuPYk7N1NpzV4Mer2O0ORrBJvMUtuqVvgBpG6UFh_vuyfwh7j5kemiGqhtgFgqcbetrv/s1600/SSRSConfig.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;588&quot; data-original-width=&quot;1171&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPWRyVyhx-cZoR6I9tFUzZXW8gbX5u8s4y3Rxf52_bhGMXPmmoMdGUl4tYXGMgeKOL4t_YpeBWVuPYk7N1NpzV4Mer2O0ORrBJvMUtuqVvgBpG6UFh_vuyfwh7j5kemiGqhtgFgqcbetrv/s640/SSRSConfig.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Analysis&lt;/h2&gt;
&lt;br /&gt;
As you see from the screenshot, the data is missing in all the textboxes except the last one. This had us bewildered for a while and we started the analyzing the behavior to understand the root cause for this issue.&lt;br /&gt;
We tried exporting this to Excel and CSV and the screenshots are as below&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh17MYZFylH0h31ie0EtP8ISEzTD_U_yHjb6HHtp_m2akpJUjNDqBTdHWuBGnk9ntikpkZ8BSRDserjy9_SoG1ldvpeLHOEqC6K3ru0J-CcR-nYwlb-1WQjPHUAqDmsi-Rx3CWcZLfXCvKq/s1600/SSRSConfig.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;656&quot; data-original-width=&quot;1255&quot; height=&quot;334&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh17MYZFylH0h31ie0EtP8ISEzTD_U_yHjb6HHtp_m2akpJUjNDqBTdHWuBGnk9ntikpkZ8BSRDserjy9_SoG1ldvpeLHOEqC6K3ru0J-CcR-nYwlb-1WQjPHUAqDmsi-Rx3CWcZLfXCvKq/s640/SSRSConfig.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKlsW2-tFo8la_wYxy6rkPiimvmkmrPRdeqdRWKxqc0AKkLSR64wYB8i7gWpVKDy8fdndoJHlu3V16wy7AY-OxVd4StrypAH7BzwSceGUZZIj6q5nucZ4zjSZTYNpm8ynjivQT8iTXC5Kz/s1600/SSRSConfig.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;889&quot; data-original-width=&quot;694&quot; height=&quot;640&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKlsW2-tFo8la_wYxy6rkPiimvmkmrPRdeqdRWKxqc0AKkLSR64wYB8i7gWpVKDy8fdndoJHlu3V16wy7AY-OxVd4StrypAH7BzwSceGUZZIj6q5nucZ4zjSZTYNpm8ynjivQT8iTXC5Kz/s640/SSRSConfig.png&quot; width=&quot;497&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
The two screenshots showed that data was in fact available inside the tables which made it clear the issue was with the HTML viewer in the VS shell ( SSDT 15.5 Version)&lt;br /&gt;
Our next attempt was to use a matrix container instead of table container and see if the issue persists,&lt;br /&gt;
As per this, created a matrix container and added the same columns inside and the screenshot is as below&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjBThYNydqoqFG2VI0kfBlxQ9532IfJADIggEu3AMVTbUD-mMl2TBGoLbtU1J1K9PNhVeV3ohWEHqsbAwE3_GIiF7ytAX6SxDlk_P4omW6sW8KaDlvS5nMi1HuT1utN0g3-CjxvwCf_ZH8/s1600/SSRSConfig.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;468&quot; data-original-width=&quot;1512&quot; height=&quot;196&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjBThYNydqoqFG2VI0kfBlxQ9532IfJADIggEu3AMVTbUD-mMl2TBGoLbtU1J1K9PNhVeV3ohWEHqsbAwE3_GIiF7ytAX6SxDlk_P4omW6sW8KaDlvS5nMi1HuT1utN0g3-CjxvwCf_ZH8/s640/SSRSConfig.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
The original table and matrix is shown above as in the designer. The main table&#39;s visibility option is set to hide and matrix is set to visible.&amp;nbsp; The behavior would be as below&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpNKAYO15xhnQ2r47JC9UnXCuoIHQPsdk-9-hxjRji5Sn5GS94FntQV5TAk3QwxFUQXhLdFUNV15BG8xzTGRbCOIcgIrxxAr0O7jv5x8JDZUtBfZs-M3q3lPkynoxGf3nJdqTweS1GTGsb/s1600/SSRSConfig.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;655&quot; data-original-width=&quot;1143&quot; height=&quot;364&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpNKAYO15xhnQ2r47JC9UnXCuoIHQPsdk-9-hxjRji5Sn5GS94FntQV5TAk3QwxFUQXhLdFUNV15BG8xzTGRbCOIcgIrxxAr0O7jv5x8JDZUtBfZs-M3q3lPkynoxGf3nJdqTweS1GTGsb/s640/SSRSConfig.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
As you see, we were able to display the data properly inside matrix. One thing to note here is that all columns are included inside grouping columns in the matrix with no values in detail columns (you can see the mandatory detail column blank in the last screenshot. Its column visibility would be set to hide for it to not generate the blank column)&lt;br /&gt;
From the above trials, the major things to note are&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;The data is not visible while displayed inside a table&lt;/li&gt;
&lt;li&gt;The data is visible inside a matrix only when its inside a group.&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
Taking these things to consideration the next step was to check the report code behind&lt;/div&gt;
&lt;div&gt;
As you&#39;re probably aware, the code behind can be viewed by right clicking the report file (rdl) from solution and choosing view code. The code behind would be in XML format.&lt;/div&gt;
&lt;div&gt;
The code for the report looks like this&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhw6ip_kIvTkEmtolkZi_a58o8K5raKbGtZvhqsVya3WvZ6J5Ur_uc7S-GWpJFN8_1lI2sN1B321NKCYAqRx55DQox3EcILVmkLuuTAQ7Ia4zIwVMUv4OwyjLHJcMg2mB6zCNnjqpTUtsbX/s1600/SSRSConfig.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;469&quot; data-original-width=&quot;1600&quot; height=&quot;185&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhw6ip_kIvTkEmtolkZi_a58o8K5raKbGtZvhqsVya3WvZ6J5Ur_uc7S-GWpJFN8_1lI2sN1B321NKCYAqRx55DQox3EcILVmkLuuTAQ7Ia4zIwVMUv4OwyjLHJcMg2mB6zCNnjqpTUtsbX/s640/SSRSConfig.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Fortunately I had another instance of SSRS in my machine which was of version 2012.&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
I compared code behind of a similar report to the above and found that in the current version we have an additional section on top which includes the font family information (highlighted in blue above).&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
I changed the font to Arial which was what my previous version of SSRS was using inside and tried running the report.&lt;br /&gt;
The report now looked like this&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuALeqDYS9fOPH39LNea_fpr5k_lfEwxE9XQOAPOQ4Pdpgmzl19te7Hn6KTB8u0CvIdKoYMH4HAJo8PCGqKd38EaY68qpXrbL8pqLUG_Eo2-9qd9rVrOReyq6_12vgm2LH1iA8piNfN48q/s1600/SSRSConfig.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;558&quot; data-original-width=&quot;1152&quot; height=&quot;308&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuALeqDYS9fOPH39LNea_fpr5k_lfEwxE9XQOAPOQ4Pdpgmzl19te7Hn6KTB8u0CvIdKoYMH4HAJo8PCGqKd38EaY68qpXrbL8pqLUG_Eo2-9qd9rVrOReyq6_12vgm2LH1iA8piNfN48q/s640/SSRSConfig.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
So as it turns out, the issue was with the default font family which was used inside SSDT.&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Conclusion&lt;/h2&gt;
&lt;/div&gt;
&lt;div&gt;
As shown by the illustration above, SSDT 15.5 has an issue with preview mode not displaying full data correctly for tables and in matrix detailed rows.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
The issue seems to be caused due to the default font (&lt;b&gt;Segoe UI&lt;/b&gt;) being applied by the HTML preview screen. Changing the font seems to fix the issue. So whenever you face similar issue, try tweaking the font by opening the code behind to ensure its not a font based issue before you look for the other causes.&lt;/div&gt;
&lt;div&gt;
Hopefully this article could save you couple of hours of effort in fixing the issue caused due to font setting in the future.&lt;/div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
References&lt;/h2&gt;
&lt;div&gt;
The sample RDL along with table creation script can be downloaded from the below link&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;https://drive.google.com/file/d/1DQRGnlU-KrIhiQKrIOGAqbhS-ZQo5Yyt/view?usp=sharing&quot;&gt;Report Link&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
</description><link>http://visakhm.blogspot.com/2018/02/ssrs-2017-tips-solving-default-font.html</link><author>noreply@blogger.com (Visakh Murukesan)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5gInO9FLXaY6Taaks4EyCbsLAg-GmI0kc6yyWc6wOGeWuK0YxEFs-x_LEJUBu5EYXPlqbsC5p9vjKXdwxzKY_XEdjUUqB5F3pk1xMKK0fhaSR9P8Sn8-RRjcdeIOR4w_ymcLabJ_hgM2w/s72-c/ss.png" height="72" width="72"/><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7998687752365941655.post-5412805707960968449</guid><pubDate>Wed, 08 Nov 2017 10:42:00 +0000</pubDate><atom:updated>2017-11-08T16:12:19.380+05:30</atom:updated><title>SQL Tips: Demystifying FORMAT behavior in Datetime vs Time Values</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Introduction&lt;/h2&gt;
&lt;br /&gt;
Since SQL 2012 , one of the functions which I used quite regularly on my day to day coding has been the FORMAT function.&lt;br /&gt;
The major use case has been in formatting date and time based values to custom date and time formats. Though I rely upon front end to do the formatting on most occasions, sometimes we&#39;re required to do it at database layer as some tasks would be data feeds like Excel exports where formatted data has to be exported to Excel sheets.&lt;br /&gt;
This article clarifies the difference in the behavior of FORMAT function that you shall notice while working with datetime vs time based values&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Scenario&lt;/h2&gt;
&lt;div&gt;
Now lets set the scene for the topic on hand&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Consider this small code snippet where I&#39;m trying to format a standard datetime value to the format dd MMM yyyy hh:mm:ss AM/PM.&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;declare @dt datetime = &#39;20171025 13:14:45&#39;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;SELECT FORMAT(@dt,&#39;dd MMM yyyy hh:mm:ss tt&#39;)&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
The result is shown below&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEVdhwMfSUtGZRD5HzA1-DSiaLD7RvPh2ichxkJTVMxKXsQL1ndnJluMggyZKkDyu54toxpOLowKgH3O708RpIaAMZP2G3bTS2ZF3nlKjiEYltENcIhB8tVEV5TkxwjgNN535HroJLZXoj/s1600/Format.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;188&quot; data-original-width=&quot;405&quot; height=&quot;148&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEVdhwMfSUtGZRD5HzA1-DSiaLD7RvPh2ichxkJTVMxKXsQL1ndnJluMggyZKkDyu54toxpOLowKgH3O708RpIaAMZP2G3bTS2ZF3nlKjiEYltENcIhB8tVEV5TkxwjgNN535HroJLZXoj/s320/Format.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
All is as expected and we are good&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Now lets try using FORMAT function on a time value&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;declare @tm time = &#39;14:34:56&#39;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;SELECT FORMAT(@tm,&#39;hh:mm:ss tt&#39;)&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
And the result is as below&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcsS_k3W06qIHVK5C-p8kvmeUZjRaXWGexgMlswZAK91PrMQPjbPZO_QgTr9VgzvHmBqEcw86B_Wzv9MO8y1iIJ1Q7sEE4clXnqYuASGw2KYZd9EcfdHfQqrrZ2EY-eSmOuoM3w1cntY1u/s1600/Format.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;179&quot; data-original-width=&quot;269&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcsS_k3W06qIHVK5C-p8kvmeUZjRaXWGexgMlswZAK91PrMQPjbPZO_QgTr9VgzvHmBqEcw86B_Wzv9MO8y1iIJ1Q7sEE4clXnqYuASGw2KYZd9EcfdHfQqrrZ2EY-eSmOuoM3w1cntY1u/s1600/Format.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
This was something totally unexpected. The expectation was to get the time based value like 02:34:56 PM&amp;nbsp;&lt;/div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Explanation&lt;/h2&gt;
&lt;div&gt;
I decided to do some analysis on FORMAT function to get to the bottom of this problem.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
The official documentation of FORMAT function also clearly states supporting date, datetime, datetime2, time datatypes as seen from here&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;https://docs.microsoft.com/en-us/sql/t-sql/functions/format-transact-sql&quot;&gt;https://docs.microsoft.com/en-us/sql/t-sql/functions/format-transact-sql&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
But the catch is in the mapping table&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
If you check the documentation, &lt;b&gt;time &lt;/b&gt;datatype alone is mapped to .Net datatype of &lt;b&gt;TimeSpan &lt;/b&gt;while &lt;b&gt;date, datetime, datetime2&lt;/b&gt; are all mapped to &lt;b&gt;DateTime &lt;/b&gt;datatype in .Net&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
The TimeSpan datatype accept custom specifiers as aid out by the article below&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-timespan-format-strings&quot;&gt;TimeSpan Accepted Format Specifiers&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
On contrast, the acceptable specifiers for DateTime are the below&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings&quot;&gt;DateTime Accepted Format Specifiers&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Reading through the link you can note the below points regarding Format Specifiers&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;TimeSpan doesnt accept : as a valid separator whereas DateTime accepts : as a valid time separator&lt;/li&gt;
&lt;li&gt;TimeSpan requires using \ as escape character to escape the : seperators&lt;/li&gt;
&lt;li&gt;TimeSpan accepts only h or hh as specifier for hour part always returned in 24hr clock whereas DateTime accepts both lower and upper case (h,hh,H,HH) with lowercase giving time in 12h and uppercase in 24hr clock&lt;/li&gt;
&lt;li&gt;DateTime accepts t or tt to return first or full part of AM/PM designator but TimeSpan doesnt support this as it always returns time in 24hr clock&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
Based on the above comparison we can see that for getting time value in hh:mm:ss format we need to use FORMAT function like this&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;declare @tm time = &#39;02:34:56&#39;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;SELECT FORMAT(@tm,&#39;hh\:mm\:ss&#39;)&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
And result is as shown&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiml5I4MAXLOarnxKWGK8wgqNlOix0wdAy1Bu0ik995qL-qkRzu5DI1OiyjRHoHQdFNgeGO6qXoI84dhjJsgBShqTHcr-9Fz-vzzIo8HFYN8pr3D90KpSzUQB4XwYQuZk4qW1-H0F0lq-7v/s1600/Format.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;181&quot; data-original-width=&quot;270&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiml5I4MAXLOarnxKWGK8wgqNlOix0wdAy1Bu0ik995qL-qkRzu5DI1OiyjRHoHQdFNgeGO6qXoI84dhjJsgBShqTHcr-9Fz-vzzIo8HFYN8pr3D90KpSzUQB4XwYQuZk4qW1-H0F0lq-7v/s1600/Format.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
If you want to get format as 02:34:56 PM&amp;nbsp; you need to cast it to datetime first before applying FORMAT function as per the stated points above&lt;/div&gt;
&lt;div&gt;
i.e like&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;declare @tm1 time = &#39;02:34:56&#39;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;SELECT FORMAT(CAST(@tm1 as datetime),&#39;hh:mm:ss tt&#39;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
And you shall get the intended result as shown&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLIYmLJO4jMYaWbvy2MAn18o0hvdF4hBCE7ztGG6jyJda-xkVEC0hSdmVmtp-UkXIx10H_-JD984A6cwXQHWGzVMhbZI6RfvIzQ0u3ilg86gd8ax-31_o78WmL2CjnhkIlDHq_b5sQk0pz/s1600/Format.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;168&quot; data-original-width=&quot;428&quot; height=&quot;156&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLIYmLJO4jMYaWbvy2MAn18o0hvdF4hBCE7ztGG6jyJda-xkVEC0hSdmVmtp-UkXIx10H_-JD984A6cwXQHWGzVMhbZI6RfvIzQ0u3ilg86gd8ax-31_o78WmL2CjnhkIlDHq_b5sQk0pz/s400/Format.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Conclusion&lt;/h2&gt;
&lt;div&gt;
As seen from the illustration above, FORMAT function handles the datetime and time fields differently due to the difference in mapped .Net datatypes.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</description><link>http://visakhm.blogspot.com/2017/11/sql-tips-demystifying-format-behavior.html</link><author>noreply@blogger.com (Visakh Murukesan)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEVdhwMfSUtGZRD5HzA1-DSiaLD7RvPh2ichxkJTVMxKXsQL1ndnJluMggyZKkDyu54toxpOLowKgH3O708RpIaAMZP2G3bTS2ZF3nlKjiEYltENcIhB8tVEV5TkxwjgNN535HroJLZXoj/s72-c/Format.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7998687752365941655.post-1937046267686925482</guid><pubDate>Tue, 31 Oct 2017 09:50:00 +0000</pubDate><atom:updated>2017-10-31T15:20:00.276+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Agent_Datetime</category><title>SQL Tips: Exploring Agent_Datetime Function</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Introduction&lt;/h2&gt;
&lt;br /&gt;
Recently there was a discussion in one of the forums which helped me to learn about a function which has been there for a long time&amp;nbsp; in SQLServer and had eluded my knowledge till now.&lt;br /&gt;
This article explains on the details of the function along with the common use cases.&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Agent_Datetime&amp;nbsp;&lt;/h2&gt;
The function of interest is agent_datetime.&lt;br /&gt;
It resides in the msdb database of a SQLServer instance and accepts two arguments. First argument would be an eight digit integer which represents date portion of a datetime value. The second argument would be a six digit integer representing the time part of the datetime value in hours,minutes and seconds format.&lt;br /&gt;
&lt;br /&gt;
The function can be invoked as below&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;b&gt;Select msdb.dbo.agent_datetime(20171027,231134)&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
The result would be as below&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgiLEN4UUPxa8uYMZSDIV66vkkmBl7ed7_rXr1km-0Fk2CA1wqUr3nbqmqp9S4CT1DcyOw76fAdYeqaYJ2nOSvIiLkl3-GudT-b3Jtx7DpDlXu3ck5TpjieWqNn6GYxASOkQYkR459BuHa/s1600/Agentdt.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;181&quot; data-original-width=&quot;389&quot; height=&quot;148&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgiLEN4UUPxa8uYMZSDIV66vkkmBl7ed7_rXr1km-0Fk2CA1wqUr3nbqmqp9S4CT1DcyOw76fAdYeqaYJ2nOSvIiLkl3-GudT-b3Jtx7DpDlXu3ck5TpjieWqNn6GYxASOkQYkR459BuHa/s320/Agentdt.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
As you see it created a datetime value&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;2017-10-27 23:11:34.000&lt;/span&gt; from the two integer values passed.&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Background&lt;/h2&gt;
There is a clear intention behind naming the function as Agent_Datetime and placing it within the msdb database.&lt;br /&gt;
The function is not officially documented and is basically used internally for converting the date and time values related to sql jobs from msdb system tables.&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Use Cases&lt;/h2&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
1. Get SQL Agent related datetime values from integer based columns in msdb catalog objects&lt;/h4&gt;
There are few columns like for ex. rundate and runtime in sysjobhistory table which represented a date value stored as integer internally.&lt;br /&gt;
So query like below&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;SELECT j.name,dbo.agent_datetime(jh.run_date,jh.run_time) AS RunDate&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;FROM dbo.sysjobs j&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;JOIN dbo.sysjobhistory jh&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;ON jh.job_id = j.job_id&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Will give you the list of jobs with their run dates in proper datetime format from &lt;b&gt;msdb &lt;/b&gt;database.&lt;br /&gt;
&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
2. Generic use to generate datetime values from integer based date and time fields&lt;/h4&gt;
&lt;div&gt;
Though the function is created in msdb we&#39;re free to use it in our user databases to merge integer based date and time values to a proper datetime value.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
As an illustration see the below&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifA6xnTfr6TV4qHe-JidMMcyyzxj_utZDEjpeT6bmWWw9OfIMGfHinxBuudDnfa-0QURGyDdV8f8ayl-z6Xc_yXCNa6cfB96Be881bTZz6vxihS47xc3-dw1RJI28IbwYrwb-6OI8CEkDJ/s1600/Agentdt.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;690&quot; data-original-width=&quot;339&quot; height=&quot;640&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifA6xnTfr6TV4qHe-JidMMcyyzxj_utZDEjpeT6bmWWw9OfIMGfHinxBuudDnfa-0QURGyDdV8f8ayl-z6Xc_yXCNa6cfB96Be881bTZz6vxihS47xc3-dw1RJI28IbwYrwb-6OI8CEkDJ/s640/Agentdt.png&quot; width=&quot;313&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
The above screenshot shows three different illustrations regarding use of agent_datetime function with different types of arguments.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
The first example passes 8 digit&amp;nbsp;date and 6 digit&amp;nbsp;time based integer values and merges them into a proper datetime value.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
The second examples shows what happens when you pass a 4 digit integer value for the time part instead of the expected 6 digits. The function will interpret it in the format mm:ss and returns merged date with the minute and seconds value. If you have only hour and minute parts make sure you pass it in hhmm00 format (i.e adding 0s for the missing seconds)&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
The final illustration depicts the case where you&#39;ve only a date part to pass. In this case, you need to pass a default value of &#39;&#39; for the time part when you invoke the agent_datetime function. The function will return full datetime value with time part being default (00:00:00)&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2 style=&quot;clear: both; text-align: left;&quot;&gt;
Conclusion&lt;/h2&gt;
&lt;div&gt;
As seen from the illustrations above the &lt;b&gt;msdb.dbo.agent_datetime&lt;/b&gt; scalar function can be used to generate proper datetime values from two separate integer based date and time values. It can be used for sql agent based catalog queries in msdb as well as for the queries in other databases.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
The only caveat is that since its undocumented its better to refrain from using this on production code especially for the cases where we want the query to be run periodically.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
For adhoc querying we shall use the function as a quick way to generate datetime values from integer date and time equivalents.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</description><link>http://visakhm.blogspot.com/2017/10/sql-tips-exploring-agentdatetime.html</link><author>noreply@blogger.com (Visakh Murukesan)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgiLEN4UUPxa8uYMZSDIV66vkkmBl7ed7_rXr1km-0Fk2CA1wqUr3nbqmqp9S4CT1DcyOw76fAdYeqaYJ2nOSvIiLkl3-GudT-b3Jtx7DpDlXu3ck5TpjieWqNn6GYxASOkQYkR459BuHa/s72-c/Agentdt.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7998687752365941655.post-4688099737030436382</guid><pubDate>Tue, 24 Oct 2017 11:24:00 +0000</pubDate><atom:updated>2017-10-24T16:54:25.450+05:30</atom:updated><title>SQL 2017 Tips: Tweaking IDENTITY_CACHE Setting to Avoid IDENTITY Column Gaps </title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Introduction&lt;/h2&gt;
In my discussions with my fellow colleagues as well as on my online interactions with the developer community, I&#39;ve come across a good amount of cases where people have raised a concern over the IDENTITY behavior in SQLServer.&lt;br /&gt;
As you probably know, IDENTITY based columns have a tendency to jump values whenever server restart occurs in the recent versions. Though this doesn&#39;t cause any problems regarding the sequence of values being generated, there are some use cases where I&#39;ve seen this causing an issue for the application especially when the column is being expected to maintain the continuity in values and avoid gaps. Though its certainly a debatable topic on whether&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Root Cause&lt;/h2&gt;
In reality, the cause of this issue is purely intentional and by design.&lt;br /&gt;
&lt;br /&gt;
The IDENTITY values are cached for improving the performance of insert operations on tables with IDENTITY columns. So if we had to dispense with this IDENTITY behavior our only option was to utilize the trace flag 272. This had to be set either using DBCC commands or using -T startup option.&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
SCOPED CONFIGURATION&amp;nbsp;&lt;/h2&gt;
&lt;br /&gt;
SQL 2016 introduced SCOPED CONFIGURATIONs which allows configuration settings to be applied at a database instance level.&lt;br /&gt;
In SQL 2017 there was a new option added to it namely IDENTITY_CACHE which can be used for solving the above issue. Once set for a database, this setting ensures the identity values are not getting cached within the database. This will avoid the problem of IDENTITY column jumping values during the restart of a SQL Server.&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Syntax&lt;/h2&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
The scoped configuration setting for IDENTITY_CACHE can be enabled by using a statement as below&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;span class=&quot;hljs-keyword&quot; style=&quot;color: #0101fd; font-family: Consolas, Menlo, Monaco, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace, sans-serif; font-size: 14px; white-space: pre;&quot;&gt;ALTER&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #222222; font-family: Consolas, Menlo, Monaco, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace, sans-serif; font-size: 14px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hljs-keyword&quot; style=&quot;color: #0101fd; font-family: Consolas, Menlo, Monaco, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace, sans-serif; font-size: 14px; white-space: pre;&quot;&gt;DATABASE&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #222222; font-family: Consolas, Menlo, Monaco, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace, sans-serif; font-size: 14px; white-space: pre;&quot;&gt; SCOPED CONFIGURATION &lt;/span&gt;&lt;span class=&quot;hljs-keyword&quot; style=&quot;color: #0101fd; font-family: Consolas, Menlo, Monaco, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace, sans-serif; font-size: 14px; white-space: pre;&quot;&gt;SET&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #222222; font-family: Consolas, Menlo, Monaco, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace, sans-serif; font-size: 14px; white-space: pre;&quot;&gt; IDENTITY_CACHE=&lt;/span&gt;&lt;span class=&quot;hljs-keyword&quot; style=&quot;color: #0101fd; font-family: Consolas, Menlo, Monaco, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace, sans-serif; font-size: 14px; white-space: pre;&quot;&gt;OFF&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #222222; font-family: Consolas, Menlo, Monaco, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace, sans-serif; font-size: 14px; white-space: pre;&quot;&gt; ; &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #f9f9f9; color: #222222; font-family: Consolas, Menlo, Monaco, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace, sans-serif; font-size: 14px; white-space: pre;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
Once above statement is executed the effect would be same as setting the trace flag 272 but at the database level.&lt;br /&gt;
This provides an added advantage to us due to the fact that we shall set it at the database level only for the databases where handling gaps in Sequence/Identity columns is a business problem and has to be avoided.&lt;br /&gt;
Wherever we need an optimal insert performance and cares little on the gaps in the values, we shall still keep the setting to the default which is ON where it maintains the cache for the values.&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Conclusion&lt;/h2&gt;
&lt;div&gt;
As explained above, the introduction of the new option in scoped configuration for controlling the identity cache behavior at the database level is very helpful in avoiding the identity value gaps issue in SQL 2017&lt;/div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
References&lt;/h2&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-database-scoped-configuration-transact-sql&quot;&gt;https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-database-scoped-configuration-transact-sql&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
</description><link>http://visakhm.blogspot.com/2017/10/sql-2017-tips-tweaking-identitycache.html</link><author>noreply@blogger.com (Visakh Murukesan)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7998687752365941655.post-6913486401688424105</guid><pubDate>Sat, 05 Aug 2017 11:02:00 +0000</pubDate><atom:updated>2017-08-05T16:32:50.929+05:30</atom:updated><title>SSIS Tips: Handling UTF 8 Based File Data</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Introduction&lt;/h2&gt;
&lt;div&gt;
Quite a few times there were cases where we had to transfer CSV data containing non English based characters to SQLServer database. Though it seems straightforward there are few things we need to consider while working with CSV containing non English characters. This post explains the steps that shall be followed while transferring UTF 8 based data from a CSV onto a SQLServer based relational database system&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Scenario&lt;/h2&gt;
&lt;div&gt;
Consider the case where we&#39;ve a CSV file with the below data&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVKczfbXch024LlOP6pXqrGlKNumFsYC6_vI8iItZqWMgz8boDKN0aVwseafUaKm_2mdK14eqnRoMYHLhbng7TbNZmficbYucCkb8I6jxt41piDpmBMUnXZjxbnk9VQWDCAZMkbf4vtElq/s1600/UTF8.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;172&quot; data-original-width=&quot;186&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVKczfbXch024LlOP6pXqrGlKNumFsYC6_vI8iItZqWMgz8boDKN0aVwseafUaKm_2mdK14eqnRoMYHLhbng7TbNZmficbYucCkb8I6jxt41piDpmBMUnXZjxbnk9VQWDCAZMkbf4vtElq/s1600/UTF8.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
As you see from the above the file has a column which stores non English based data. The requirement was to get this data transferred to a SQLServer database for doing further manipulations with them.&lt;/div&gt;
&lt;div&gt;
Given this requirement our straightforward way would be to use a data flow task with a flat file source and an OLEDB destination to connect to the SQLServer db.&lt;/div&gt;
&lt;div&gt;
Lets see what happens when we try to use the standard DFT task for this case&lt;/div&gt;
&lt;div&gt;
Given below is the screenshot of the standard data flow task using non-unicode datatype I tried to use&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEio0uAIfp9bJQuuxn1JAvFiZtcWKxlMydWyoKXi8qKLAqc2KRbKRDdmlvFvW9Gv8IU_3TKBgfQT86mYLiQRhSwutwvmIuKQya0dBW0SipKGWwrUy6sBHQaIsc7Z13nzv1Vot6zMZknPcG9N/s1600/DFT.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;293&quot; data-original-width=&quot;953&quot; height=&quot;122&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEio0uAIfp9bJQuuxn1JAvFiZtcWKxlMydWyoKXi8qKLAqc2KRbKRDdmlvFvW9Gv8IU_3TKBgfQT86mYLiQRhSwutwvmIuKQya0dBW0SipKGWwrUy6sBHQaIsc7Z13nzv1Vot6zMZknPcG9N/s400/DFT.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
As you see from the above it complains of data conversion issue between unicode and non-unicode data types.&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Now lets try using an unicode datatype and see what happens&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhI5nGLzKwYzNDZrgiHlq2lAg7ifD_-HNBn7MU9f3RTc8-zGZQ5myrXjUw_eM9uL6esn5xlVnRPI_DemCzR_eUABAIUXRMeXnj0XP4B_yq8CWg-s0OIGairgyvosu4E_2iNoYWegBbVKpVx/s1600/DFT.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;280&quot; data-original-width=&quot;986&quot; height=&quot;112&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhI5nGLzKwYzNDZrgiHlq2lAg7ifD_-HNBn7MU9f3RTc8-zGZQ5myrXjUw_eM9uL6esn5xlVnRPI_DemCzR_eUABAIUXRMeXnj0XP4B_yq8CWg-s0OIGairgyvosu4E_2iNoYWegBbVKpVx/s400/DFT.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Now we get an error stating that it cant convert between the two code pages. This clearly implies we cant use the default OLEDB destination in the case of UTF - 8 based file data.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Now lets try using the next possible option i.e. with ADO .Net destination.&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
The data flow for this case is as below&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUkiIoALfMuxghIGAJ_ONf1g8js-L8XfnD8H6_uDCs3EA4Q6Gq1MzfgJVXEq6KJp_jBNSmGWgwGvw3peTs1Q0KPKx8iZm5Q4a-1MmOrf4XiRPMVDeKjd7kvlGSWCJZpS4ZvXpva77XfuEC/s1600/DFT.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;311&quot; data-original-width=&quot;383&quot; height=&quot;259&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUkiIoALfMuxghIGAJ_ONf1g8js-L8XfnD8H6_uDCs3EA4Q6Gq1MzfgJVXEq6KJp_jBNSmGWgwGvw3peTs1Q0KPKx8iZm5Q4a-1MmOrf4XiRPMVDeKjd7kvlGSWCJZpS4ZvXpva77XfuEC/s320/DFT.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
The column will be of unicode datatype (nchar, nvarchar) in the database.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Once executed you can check the table to see that data is getting populated correctly&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiD0w1C5uSe98Se72enmq4jzjmmcP0qs8IYmAoYxWmBdTt2sfzO_uNiKwutXTj6ZiM9l3NMwmBwuPsfzuEJ_P6COpCjVT-J-uC2ZkyHeiGDV78KAdKAJW6n0HZJ4Nd5HDNx4qvl64MP_WSD/s1600/sql.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;338&quot; data-original-width=&quot;258&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiD0w1C5uSe98Se72enmq4jzjmmcP0qs8IYmAoYxWmBdTt2sfzO_uNiKwutXTj6ZiM9l3NMwmBwuPsfzuEJ_P6COpCjVT-J-uC2ZkyHeiGDV78KAdKAJW6n0HZJ4Nd5HDNx4qvl64MP_WSD/s320/sql.png&quot; width=&quot;244&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
As seen from the above results data got transferred correctly this time to the SQLServer table.&lt;/div&gt;
&lt;h2 style=&quot;clear: both; text-align: left;&quot;&gt;
Conclusion&lt;/h2&gt;
&lt;div&gt;
By virtue of the above illustration, its clear that for transferring UTF-8 based file data to SQLServer using SSIS we need to do the below&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
1. Use UTF-8 based codepage (65001) in the Flat File connection manager&lt;/div&gt;
&lt;div&gt;
2. Use ADO .Net destination task inside data flow task&lt;/div&gt;
&lt;div&gt;
3. Use a Unicode based datatype for the table column like nchar, nvarchar&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
References&lt;/h2&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;https://docs.microsoft.com/en-us/sql/integration-services/data-flow/ado-net-destination&quot;&gt;ADO .Net destination&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;https://msdn.microsoft.com/en-us/library/ee254081(v=bts.10).aspx&quot;&gt;Code Page Flat Files&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</description><link>http://visakhm.blogspot.com/2017/08/ssis-tips-handling-utf-8-based-file-data.html</link><author>noreply@blogger.com (Visakh Murukesan)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVKczfbXch024LlOP6pXqrGlKNumFsYC6_vI8iItZqWMgz8boDKN0aVwseafUaKm_2mdK14eqnRoMYHLhbng7TbNZmficbYucCkb8I6jxt41piDpmBMUnXZjxbnk9VQWDCAZMkbf4vtElq/s72-c/UTF8.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7998687752365941655.post-1639807240075828805</guid><pubDate>Tue, 20 Jun 2017 03:40:00 +0000</pubDate><atom:updated>2017-06-20T09:10:22.477+05:30</atom:updated><title>SQL 2017 Tips: Avoiding Gaps in IDENTITY, SEQUENCE Based Column Values</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Scenario&lt;/h2&gt;
&lt;br /&gt;
One of the common conversations I&#39;ve come across in a typical work day is as below&lt;br /&gt;
&lt;br /&gt;
Emp X: I just found that the IDENTITY column values for couple of tables have jumped to a new range&lt;br /&gt;
Emp Y: Can you check if there was any server restart?&lt;br /&gt;
Emp X: Oh yes! I see it now... There was a planned server restart at night.&lt;br /&gt;
&lt;br /&gt;
The reason for this behavior is explicit.&lt;br /&gt;
&lt;br /&gt;
Server restart causes identity based columns to skip values. This is due to the fact that identity columns pre-allocates (caches) next set of values and on server restart the cache gets flushed. Once server comes back it resumes at the next value from the maximum value in the cache which creates gaps in identity sequence. This behavior started from 2012 version onwards.&lt;br /&gt;
&lt;br /&gt;
This blog discusses a new enhancement available in SQL 2017 CTP which can be used to solve the above issue&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Solution&lt;/h2&gt;
&lt;div&gt;
This behavior was explained to be by design and proposed solution was to use trace flag 272 which will allow the functionality to continue as per earlier version. The MS connect link which discusses this is given below&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;https://www.blogger.com/goog_1450462544&quot;&gt;&lt;br /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;https://connect.microsoft.com/SQLServer/feedback/details/739013/failover-or-restart-results-in-reseed-of-identity&quot;&gt;https://connect.microsoft.com/SQLServer/feedback/details/739013/failover-or-restart-results-in-reseed-of-identity&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
For setting this we had to go to SQLServer configuration manager and set trace flag 272 in the startup parameters as discussed here&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://sqlblog.com/blogs/kalen_delaney/archive/2014/06/17/lost-identity.aspx&quot;&gt;http://sqlblog.com/blogs/kalen_delaney/archive/2014/06/17/lost-identity.aspx&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
In SQL 2017, we have a good news. Microsoft has included this as a new option in S&lt;b&gt;COPED CONFIGURATION&lt;/b&gt; options for the database. The option is called &lt;b&gt;IDENTITY_CACHE&lt;/b&gt; and is included in the documentation below&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-database-scoped-configuration-transact-sql&quot;&gt;https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-database-scoped-configuration-transact-sql&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
This has two advantages over the previous trace flag based method&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
1. We can set it from management studio itself rather than setting it as a startup option from SQL Configuration Manager.&lt;/div&gt;
&lt;div&gt;
2. The most important advantage is that we can scope it to database level rather than setting it at the instance level. This makes it possible for us to have other databases co-existing in the same server instance with new behavior enabled i.e. with gaps.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
The complete syntax for the feature is as below&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;hljs-keyword&quot; style=&quot;color: #0101fd; font-family: Consolas, Menlo, Monaco, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace, sans-serif; font-size: 14px; white-space: pre;&quot;&gt;ALTER&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #222222; font-family: Consolas, Menlo, Monaco, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace, sans-serif; font-size: 14px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hljs-keyword&quot; style=&quot;color: #0101fd; font-family: Consolas, Menlo, Monaco, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace, sans-serif; font-size: 14px; white-space: pre;&quot;&gt;DATABASE&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #222222; font-family: Consolas, Menlo, Monaco, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace, sans-serif; font-size: 14px; white-space: pre;&quot;&gt; SCOPED CONFIGURATION &lt;/span&gt;&lt;span class=&quot;hljs-keyword&quot; style=&quot;color: #0101fd; font-family: Consolas, Menlo, Monaco, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace, sans-serif; font-size: 14px; white-space: pre;&quot;&gt;SET&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #222222; font-family: Consolas, Menlo, Monaco, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace, sans-serif; font-size: 14px; white-space: pre;&quot;&gt; IDENTITY_CACHE=&lt;/span&gt;&lt;span class=&quot;hljs-keyword&quot; style=&quot;color: #0101fd; font-family: Consolas, Menlo, Monaco, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace, sans-serif; font-size: 14px; white-space: pre;&quot;&gt;OFF&lt;/span&gt;&lt;span style=&quot;background-color: #f9f9f9; color: #222222; font-family: Consolas, Menlo, Monaco, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace, sans-serif; font-size: 14px; white-space: pre;&quot;&gt; ;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: #f9f9f9; color: #222222; font-family: Consolas, Menlo, Monaco, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace, sans-serif; font-size: 14px; white-space: pre;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
Once you set it at a database level, the server restart doesn&#39;t cause any gaps in the IDENTITY objects in the database, which is in line with the behavior before SQL 2012 version.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
This small but very useful enhancement will certainly help the developers to set IDENTITY value behavior in a database as per their requirement.&lt;/div&gt;
&lt;/div&gt;
</description><link>http://visakhm.blogspot.com/2017/06/sql-2017-tips-avoiding-gaps-in-identity.html</link><author>noreply@blogger.com (Visakh Murukesan)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7998687752365941655.post-1301385203110053980</guid><pubDate>Fri, 16 Jun 2017 07:27:00 +0000</pubDate><atom:updated>2017-06-16T12:57:23.958+05:30</atom:updated><title>SQL 2017 Tips: Creating Table On The Fly Onto A Specific FileGroup</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Introduction&lt;/h2&gt;
One of the frequently used and the most popular features in SQLServer is the ability to create a table on the fly based on a query. This has saved my day on numerous occasions. Only thing I was missing in this was the ability to organize the table into its own filegroup of my choice&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Why are filegroups necessary?&lt;/h2&gt;
There are various advantages of organizing tables into separate filegroups, the main among them being &amp;nbsp;the below&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;For large tables it makes sense to move them to a separate filegroup&lt;/li&gt;
&lt;li&gt;In case of tables where data size is almost same as non-clustered index size, we shall consider keeping table in one file group and index on another&lt;/li&gt;
&lt;li&gt;Organizing tables based on portfolio so that tables can be easily migrated / archived if required.&lt;/li&gt;
&lt;li&gt;Maintaining some data which is read only along with read write data in same db. In this case we can keep these tables in a separate read only file group&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
The Solution&lt;/h2&gt;
&lt;br /&gt;
The SQL 2017 CTP2 release includes a solution to the above limitation.&lt;br /&gt;
&lt;br /&gt;
The SELECT ... INTO syntax for creating the table is now extended to include the filegroup information.&lt;br /&gt;
The modified syntax would be like below&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SELECT column1, column2,.. columnN&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;INTO NewTableName&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: orange; color: blue; font-size: x-small;&quot;&gt;ON FileGroupName&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;FROM Table1 t1&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;JOIN Table2 t2&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;ON condition...&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;...&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you see the code above, the highlighted part designates the filegroup to which this new table has to be associated. Only caveat is that the filegroup must pre-exist in the database where the above query is being executed otherwise SQLServer will throw an error&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Illustration&lt;/h2&gt;
&lt;div&gt;
Lets see how we can create a new table on the fly and associate it to a newly created filegroup on the database&lt;/div&gt;
&lt;div&gt;
Steps are as outlined below&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
1. Adding a new filegroup to existing database Test2017&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;ALTER DATABASE [Test2017] ADD FILEGROUP [SupplimentaryDataFG]&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;GO&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;You can check the db properties to ensure this is created as per the below&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJvpgk0WJfullnNy1fIGM2N9lDE8FyCz1DdDjW7KBI_YYp93favXmNTEknE9jrOzkwK40ZqBC-TG4uhgUzMVLdn_9poBPwmO88ePhgadhj8TF44AjxbeaL2i7EKms9aORGh8bnfw8JyMSt/s1600/FG.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;251&quot; data-original-width=&quot;703&quot; height=&quot;114&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJvpgk0WJfullnNy1fIGM2N9lDE8FyCz1DdDjW7KBI_YYp93favXmNTEknE9jrOzkwK40ZqBC-TG4uhgUzMVLdn_9poBPwmO88ePhgadhj8TF44AjxbeaL2i7EKms9aORGh8bnfw8JyMSt/s320/FG.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
2. Associating a new file to the newly created filegroup&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
ALTER DATABASE [Test2017] &amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
ADD FILE &amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
( &amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; NAME = test1dat3, &amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; FILENAME = &#39;D:\SupplData.ndf&#39;, &amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; SIZE = 5MB, &amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; MAXSIZE = 100MB, &amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; FILEGROWTH = 5MB &amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
)&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
TO FILEGROUP [SupplimentaryDataFG];&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
The file will get created as per below&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjCSS-9E1rLMeOUokV7g7euoAeizGoQdc1zYM3CmVMbjkNGPNlrZ0CdhTEn74pG8m9APUGny3C_ran7QHkWkzUmDHVr9GV4Mv08YkAyXCvKooPizE1aN8rR0u5xCZEuXriQbh9V1AO0uoMi/s1600/FG.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;268&quot; data-original-width=&quot;700&quot; height=&quot;122&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjCSS-9E1rLMeOUokV7g7euoAeizGoQdc1zYM3CmVMbjkNGPNlrZ0CdhTEn74pG8m9APUGny3C_ran7QHkWkzUmDHVr9GV4Mv08YkAyXCvKooPizE1aN8rR0u5xCZEuXriQbh9V1AO0uoMi/s320/FG.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
3. Creating a test table on the fly on the newly created filegroup&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SELECT * INTO TestTable&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;ON SupplimentaryDataFG&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;FROM&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;(VALUES&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;(&#39;Test&#39;,1),&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;(&#39;Foo&#39;,2),&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;(&#39;Foobar&#39;,3)&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;)t(Description,Code)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Checking the table properties to see the filegroup info&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6zWEG_Vt24QIEw7wSdJhUip5bw5LtTF6QCgfJi-PtLYt0S9WB6LKviRhUqZIMzUBTO27BtxmFC4S83zWmA-cAut20wUpIo5TNqObaX6ZmwN50nRJxfsGQPDmCiLdgGWOw9Us0B9nEb6WN/s1600/TblFG.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;219&quot; data-original-width=&quot;972&quot; height=&quot;90&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6zWEG_Vt24QIEw7wSdJhUip5bw5LtTF6QCgfJi-PtLYt0S9WB6LKviRhUqZIMzUBTO27BtxmFC4S83zWmA-cAut20wUpIo5TNqObaX6ZmwN50nRJxfsGQPDmCiLdgGWOw9Us0B9nEb6WN/s400/TblFG.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Another way to check this is to use the script as option in SSMS. Script as CREATE option for the table will give the below code&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;USE [Test2017]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;GO&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;/****** Object: &amp;nbsp;Table [dbo].[TestTable] &amp;nbsp; &amp;nbsp;Script Date: 6/16/2017 7:09:03 AM ******/&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SET ANSI_NULLS ON&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;GO&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SET QUOTED_IDENTIFIER ON&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;GO&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;CREATE TABLE [dbo].[TestTable](&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;[Description] [varchar](6) NOT NULL,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;[Code] [int] NOT NULL&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;) ON &lt;span style=&quot;background-color: orange;&quot;&gt;[SupplimentaryDataFG]&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;GO&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
The highlighted part clearly shows the table to be in the new filegroup we created and associated it to&lt;/div&gt;
&lt;/div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Conclusion&lt;/h2&gt;
&lt;div&gt;
From the above illustration its pretty evident that we can create a table on the fly and associate it to any filegroup we have pre-created in the database.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
This is a very useful small enhancement which has been introduced in SQL 2017 which helps us to organize the table data into multiple filegroups simultaneously at the time of their creation on the fly using queries.&amp;nbsp;&lt;/div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
References&lt;/h2&gt;
&lt;div&gt;
&lt;a href=&quot;https://docs.microsoft.com/en-us/sql/t-sql/queries/select-into-clause-transact-sql&quot;&gt;https://docs.microsoft.com/en-us/sql/t-sql/queries/select-into-clause-transact-sql&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
</description><link>http://visakhm.blogspot.com/2017/06/sql-2017-tips-creating-table-on-fly.html</link><author>noreply@blogger.com (Visakh Murukesan)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJvpgk0WJfullnNy1fIGM2N9lDE8FyCz1DdDjW7KBI_YYp93favXmNTEknE9jrOzkwK40ZqBC-TG4uhgUzMVLdn_9poBPwmO88ePhgadhj8TF44AjxbeaL2i7EKms9aORGh8bnfw8JyMSt/s72-c/FG.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7998687752365941655.post-7510369131169531983</guid><pubDate>Wed, 03 May 2017 07:26:00 +0000</pubDate><atom:updated>2017-05-03T13:02:59.886+05:30</atom:updated><title>SSRS Tips: Creating 2012/2014 BI Templates Using VS 2015</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;
Introduction&lt;/span&gt;&lt;/h2&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;With the release of VS 2015 shell, its now possible to utilize the BI templates available init for creating SSRS reports, SSIS packages and SSAS projects compatible with server versions 2012 till 2016 from the same unified environment.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;This quick post discusses on two things that you need to consider while creating projects using VS 2015 shell which are targeted to deploy at a lower version server.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;
Scenario&lt;/span&gt;&lt;/h2&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;I had recently used VS 2015 shell for development of SSRS reports and SSIS packages for one of my projects. Our production server was still on 2014 version. As per official documentation of Microsoft VS 2015 shell can be used for creating packages, reports etc which can be deployed onto 2012, 2014 or 2016 versions. The link below has the details&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;https://docs.microsoft.com/en-us/sql/ssdt/download-sql-server-data-tools-ssdt&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;https://docs.microsoft.com/en-us/sql/ssdt/download-sql-server-data-tools-ssdt&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;As per the above I used SSDT 2015 for creating SSRS reports. After creating the reports I tested locally and once I was happy I decided to deploy the reports to the server which was in 2014 version.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;For this I went to Project &amp;nbsp;Properties and tweaked the below properties&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_yJs18lLEAM30I4N4j5H-WlacW1OxiwxOPzuBxJo83hsXuOWbTvvSZRYOa3YKQdlNJvij2dX6KarKHEVieCeQR3Akquf3QDx5HIugAHq47sQu7vvPEb0IfqBmuPAT7r0ZHpY1AEmD6gky/s1600/Projver.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;179&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_yJs18lLEAM30I4N4j5H-WlacW1OxiwxOPzuBxJo83hsXuOWbTvvSZRYOa3YKQdlNJvij2dX6KarKHEVieCeQR3Akquf3QDx5HIugAHq47sQu7vvPEb0IfqBmuPAT7r0ZHpY1AEmD6gky/s320/Projver.png&quot; width=&quot;320&quot; /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;My expectation was that by setting this property I would be able to deploy the reports to 2014 server. But to my surprise I got the below message when I tried to deploy the rdl file&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: white; font-family: &amp;quot;segoe ui&amp;quot; , &amp;quot;lucida grande&amp;quot; , &amp;quot;verdana&amp;quot; , &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif; font-size: 14px;&quot;&gt;&lt;span style=&quot;color: red;&quot;&gt;The definition of this report is not valid or supported by this version of Reporting Services. The report definition may have been created with a later version of Reporting Services, or contain content that is not well-formed or not valid based on Reporting Services schemas&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; font-family: &amp;quot;segoe ui&amp;quot; , &amp;quot;lucida grande&amp;quot; , &amp;quot;verdana&amp;quot; , &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif; font-size: 14px;&quot;&gt;&lt;span style=&quot;color: red;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;font-family: inherit; font-size: large;&quot;&gt;Solution&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;span style=&quot;background-color: white; font-family: inherit;&quot;&gt;I didn&#39;t understand why this was happening and did some analysis on other settings to see if there&#39;s anything I could find. Fortunately i was able to spot the below property&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;background-color: white; font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj559KwfEEt5ph2G01CwZkwsk1SAabnRsYYqtn6sedKbuS4McMclVPlODs3MqgD9iLyuyhbYXA5-TpC6rMpepZn2JSREP6IsiLOAcu5td7mGnlRP2P8mshdY5YVUCTJgwUJcw9maASGQcEq/s1600/server.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;179&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj559KwfEEt5ph2G01CwZkwsk1SAabnRsYYqtn6sedKbuS4McMclVPlODs3MqgD9iLyuyhbYXA5-TpC6rMpepZn2JSREP6IsiLOAcu5td7mGnlRP2P8mshdY5YVUCTJgwUJcw9maASGQcEq/s320/server.png&quot; width=&quot;320&quot; /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;background-color: white; font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white; font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span id=&quot;goog_2066726928&quot;&gt;&lt;/span&gt;&lt;span id=&quot;goog_2066726929&quot;&gt;&lt;/span&gt;This comes under Tools options and determines the Server Version to which report is to be deployed. The default value set was 13.0 which corresponds to SQL 2016. Once I changed it to 12.0 and tried deploying, the report got successfully deployed to the server.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; font-family: inherit;&quot;&gt;Something to note next time when you do deployment of SSRS,SSIS or SSAS project from VS 2015 shell to make sure deployment is successful.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;font-family: inherit; font-size: large;&quot;&gt;Conclusion&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;span style=&quot;background-color: white; font-family: inherit;&quot;&gt;Hope this quick tip will save you sometime in avoiding the above specified issue while deploying BI projects using VS 2015 shell templates&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; font-family: &amp;quot;segoe ui&amp;quot; , &amp;quot;lucida grande&amp;quot; , &amp;quot;verdana&amp;quot; , &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif; font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
</description><link>http://visakhm.blogspot.com/2017/05/ssrs-tips-creating-20122014-bi.html</link><author>noreply@blogger.com (Visakh Murukesan)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_yJs18lLEAM30I4N4j5H-WlacW1OxiwxOPzuBxJo83hsXuOWbTvvSZRYOa3YKQdlNJvij2dX6KarKHEVieCeQR3Akquf3QDx5HIugAHq47sQu7vvPEb0IfqBmuPAT7r0ZHpY1AEmD6gky/s72-c/Projver.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7998687752365941655.post-1515973378107442924</guid><pubDate>Thu, 20 Apr 2017 06:14:00 +0000</pubDate><atom:updated>2017-04-20T11:44:47.557+05:30</atom:updated><title>SQL 2017 CTP  Released!</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
SQLServer 2017 CTP is out for public preview now.&lt;br /&gt;
SQLServer 2017 has some exciting features on board like resumable online index rebuild, adaptive query query processing etc&lt;br /&gt;
Also great improvement can be seen in the performance of &amp;nbsp;datawarehouse workloads in Linux environment.&lt;br /&gt;
&lt;br /&gt;
More details on the release here&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://blogs.technet.microsoft.com/dataplatforminsider/2017/04/19/sql-server-2017-community-technology-preview-2-0-now-available/&quot;&gt;https://blogs.technet.microsoft.com/dataplatforminsider/2017/04/19/sql-server-2017-community-technology-preview-2-0-now-available/&lt;/a&gt;&lt;/div&gt;
</description><link>http://visakhm.blogspot.com/2017/04/sql-2017-ctp-released.html</link><author>noreply@blogger.com (Visakh Murukesan)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7998687752365941655.post-6343071084441176296</guid><pubDate>Thu, 13 Apr 2017 05:33:00 +0000</pubDate><atom:updated>2017-04-13T11:03:28.824+05:30</atom:updated><title>SSIS Tips: Case Study - Extracting ZenDesk data using SSIS</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Impetus&lt;/h2&gt;
&amp;nbsp;Its been a long time since I wrote a blog.&lt;br /&gt;
The main reason was that I&#39;ve been super busy with some exciting projects of late.&lt;br /&gt;
One of my recent projects had an interesting requirement which I thought would be worth sharing for the benefit of the wider audience.&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Scenario&lt;/h2&gt;
&lt;div&gt;
One of my recent BI engagements with a e-commerce customer had a use case which required customer satisfaction metrics to be captured and analyzed. The metrics were to be derived from variety of data including support tickets, delivery, feedback and notification emails etc. The client was using ZenDesk as the ticketing application. All of the above required information was tracked by means of tickets within ZenDesk so the attempt was to integrate ZenDesk data using ETL tool SSIS and use the data for analysis along with the other available data.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Illustration&lt;/h2&gt;
&lt;div&gt;
ZenDesk offers API access to its data. The attempt was to use SSIS and access the required ZenDesk data using API calls.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
For the purpose of this blog lets see a simple scenario of how SSIS can be used to call ZenDesk API for extracting tickets related data.&lt;/div&gt;
&lt;div&gt;
The details regarding ZenDesk APIs can be found here&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;https://developer.zendesk.com/rest_api/docs/core/introduction&quot;&gt;https://developer.zendesk.com/rest_api/docs/core/introduction&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Refer to the Search section which explains on various API endpoint for searching ZenDesk data. We will be utilizing this for searching and fetching the ticket information using our required filters. The search API is flexible due to the fact that it allows a set of query string parameters which can be utlized to customize our search. Some example usages are given in the below link&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;https://developer.zendesk.com/rest_api/docs/core/search&quot;&gt;https://developer.zendesk.com/rest_api/docs/core/search&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
So for our case since we require ticket information the full URL would look like below&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;https://{subdomain}&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;.zendesk.com/api/v2/search.json?sort_by=created_at&amp;amp;sort_order=asc&amp;amp;query=created&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&lt;date value=&quot;&quot;&gt;&lt;/date&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt; type:ticket&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Here subdomain represents the subdomain used while registering with ZenDesk (mostly the company name) and date value the date relative to which you want to do the search. &lt;b&gt;sort_by &lt;/b&gt;parameter is used to get the search result in chronological order.&lt;/div&gt;
&lt;div&gt;
The response for the above API call will look like this&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&quot;results&quot;:[&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&quot;url&quot;:&quot;https://&lt;subdomain&gt;.zendesk.com/api/v2/tickets/36046.json&quot;,&lt;/subdomain&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&quot;id&quot;:36046,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&quot;external_id&quot;:null,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&quot;via&quot;:{&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&quot;channel&quot;:&quot;email&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&quot;source&quot;:{&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&quot;from&quot;:{&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&quot;address&quot;:&quot;xyz2@gmail.com&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&quot;name&quot;:&quot;XYZ 2&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;},&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&quot;to&quot;:{&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&quot;name&quot;:&quot;abc.com&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&quot;address&quot;:&quot;customercare@abc.com&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;},&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&quot;rel&quot;:null&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;},&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;...],&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&quot;facets&quot;:null,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&quot;next_page&quot;:null,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&quot;previous_page&quot;:null,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&quot;count&quot;:72&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
As you see it gives a JSON response having the above structure&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
One more thing to note here is that API returns only a maximum of 100 results in a response. In case search result exceeds 100 items the response gets auto-paged at every 100 results. The url for the next page will be sent along with the response (refer to the &lt;b&gt;next_page&lt;/b&gt;/&lt;b&gt;previous_page &lt;/b&gt;elements in the above JSON)&lt;/div&gt;
&lt;div&gt;
So the cases where we have more results we need to capture &lt;b&gt;next_page &lt;/b&gt;value each time and sent a new request to the server using that url. This will continue until the last page in which case the &lt;b&gt;next_page &lt;/b&gt;value will be null.&lt;/div&gt;
&lt;div&gt;
Considering all these points a simple package for extracting ZenDesk data will look like below&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJyJIOrxhTldrxDIgmhgDKKOfNKMI982xAKNcSSJzcLPktAPwp5OkeRI4SH8VvibYf678rUMqhlkHUHJB42vwXtl2uonjHVC2JAlNg6xq2tBrEYlXJovyVuaFSRs3lhQoxfoD2EZloLiOT/s1600/Untitled.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJyJIOrxhTldrxDIgmhgDKKOfNKMI982xAKNcSSJzcLPktAPwp5OkeRI4SH8VvibYf678rUMqhlkHUHJB42vwXtl2uonjHVC2JAlNg6xq2tBrEYlXJovyVuaFSRs3lhQoxfoD2EZloLiOT/s400/Untitled.png&quot; width=&quot;252&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Now we can analyse the various tasks inside the package to understand their purpose&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;For Loop:&lt;/b&gt; The loop is included to ensure we iterate through requests until we reach the last page of our search result. It will be a simple For loop based on a counter which will be initialized to 1 and reset inside the loop when the results are completed to break from the iteration.&lt;/div&gt;
&lt;div&gt;
The &lt;b&gt;Expression Tasks&lt;/b&gt; are used to set the iterative values for request URL i.e. URL to fetch next page of results as well as for the reset of the URL and counter values&lt;/div&gt;
&lt;div&gt;
The &lt;b&gt;script task&lt;/b&gt; does the download of search results in JSON format into a text file using API call. It utilizes a HTTP connection which will use ZenDesk API URL as the source through a variable expression to pass dynamic values like date.&lt;br /&gt;
The variable expression in our case looks like below&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&quot;https://{domain}.zendesk.com/api/v2/search.json?sort_by=created_at&amp;amp;sort_order=asc&amp;amp;query=created &amp;gt;&quot; + (DT_WSTR, 30) &amp;nbsp;(DT_DBDATE) @[User::Date] + &quot; type:ticket&quot;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
The script task code will look like this&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;Dim nativeObject As Object = Dts.Connections(&quot;HTTP Connection Manager&quot;).AcquireConnection(Nothing)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Dim connection As New HttpClientConnection(nativeObject)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &#39; Download the file #1&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &#39; Save the file from the connection manager to the local path specified&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Dim filename As String = &quot;&lt;download file=&quot;&quot; path=&quot;&quot;&gt;&quot;&lt;/download&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; connection.DownloadFile(filename, True)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
The &lt;b&gt;Execute SQL Task&lt;/b&gt; uploads the JSON data from the file to a table in SQL Server database. Once data is transferred it uses a JSON parsing logic to get the individual elements out.&lt;br /&gt;
Parsing JSON can be done using native SQL functions like OPENJSON, JSON_VALUE etc if you&#39;re on SQL 2016 . This is already explained in my earlier blogs below&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;http://visakhm.blogspot.in/2016/07/whats-new-in-sql-2016-native-json.html&quot;&gt;http://visakhm.blogspot.in/2016/07/whats-new-in-sql-2016-native-json.html&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;http://visakhm.blogspot.in/2016/07/whats-new-in-sql-2016-native-json_13.html&quot;&gt;http://visakhm.blogspot.in/2016/07/whats-new-in-sql-2016-native-json_13.html&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
If you&#39;re on an earlier version of SQL, you need to use a UDF for parsing JSON like one below&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;https://www.simple-talk.com/sql/t-sql-programming/consuming-json-strings-in-sql-server/&quot;&gt;https://www.simple-talk.com/sql/t-sql-programming/consuming-json-strings-in-sql-server/&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
The SP code will look like below in that case&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;INSERT JSONData(JSON)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SELECT *&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;FROM OPENROWSET(BULK &#39;&lt;download file=&quot;&quot; path=&quot;&quot;&gt;&#39;,SINGLE_BLOB) AS t&lt;/download&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;IF OBJECT_ID(&#39;tempdb..#Temp&#39;) IS NOT NULL DROP TABLE #Temp&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SELECT f.*&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;INTO #Temp&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;FROM JSONData j&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;CROSS APPLY dbo.parseJSON(j.JSON)f&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SELECT @NextURL = StringValue&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;
&lt;div&gt;
FROM #Temp&lt;/div&gt;
&lt;div&gt;
WHERE NAME = &#39;next_page&#39;&lt;/div&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
Once you parse it you will get values of various elements within the JSON. This can be used for extracting the required information&lt;/div&gt;
&lt;div&gt;
The &lt;b&gt;next_url &lt;/b&gt;value will be captured and returned through an OUTPUT parameter back to the package. Using this we can determine whether to iterate again for the next page of results or break the loop.&lt;/div&gt;
&lt;div&gt;
Once you parse the data out to a table you can then use it for your further manipulations like aggregation etc.&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Conclusion&lt;/h2&gt;
&lt;/div&gt;
&lt;div&gt;
As seen from the above illustration you can use a simple script task utilizing a HTTP connection in SSIS package to call and extract data through ZenDesk APIs. This data can then be used for manipulations within your applications and can be utilized in BI reports, dashboards etc.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</description><link>http://visakhm.blogspot.com/2017/04/ssis-tips-case-study-extracting-zendesk.html</link><author>noreply@blogger.com (Visakh Murukesan)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJyJIOrxhTldrxDIgmhgDKKOfNKMI982xAKNcSSJzcLPktAPwp5OkeRI4SH8VvibYf678rUMqhlkHUHJB42vwXtl2uonjHVC2JAlNg6xq2tBrEYlXJovyVuaFSRs3lhQoxfoD2EZloLiOT/s72-c/Untitled.png" height="72" width="72"/><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7998687752365941655.post-6387175720146822031</guid><pubDate>Fri, 21 Oct 2016 09:08:00 +0000</pubDate><atom:updated>2016-10-21T14:38:21.346+05:30</atom:updated><title>WinSCP Tips: Passing Credentials With Special Characters</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Scenario&lt;/h2&gt;
&lt;div&gt;
Recently there was an issue faced in one of our projects on a file processing system that we designed. The file processing system was designed to process third party files which had to be downloaded from a FTP location.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
We designed a SSIS package to do the FTP download and file processing and used WinSCP for the purpose. The logic used was as per one of my earlier articles as given below&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;https://www.blogger.com/goog_66279764&quot;&gt;&lt;br /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;http://visakhm.blogspot.ae/2012/12/implementing-dynamic-secure-ftp-process.html&quot;&gt;http://visakhm.blogspot.ae/2012/12/implementing-dynamic-secure-ftp-process.html&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
On executing the package the Execute Process Task which was added to do the FTP has failed. As SSIS doesn&#39;t give too much information on the error I put a break point on the pre execute event of the execute process task and captured the full statement which is to be executed by WinSCP.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
I launched a command prompt window and tried executing the statement generated by the SSIS and got the below&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjL2U8vzIlt7iU_SzAj6plqNH0NHlULStVbmQ4Q7O7hW-tjdNJmMAWUt3-W8Qpt_Y4qLgVwc8lAgPMUsDdPHSTEceuFTWaaMxie9V_CJxO0dEBrO_8Shdu2cB0uzmdWCHievmSf6y7NqZg8/s1600/FTP.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;147&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjL2U8vzIlt7iU_SzAj6plqNH0NHlULStVbmQ4Q7O7hW-tjdNJmMAWUt3-W8Qpt_Y4qLgVwc8lAgPMUsDdPHSTEceuFTWaaMxie9V_CJxO0dEBrO_8Shdu2cB0uzmdWCHievmSf6y7NqZg8/s400/FTP.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
As seen from the above screenshot I got an access denied error. I checked the credentials again and tried them on WinSCP client installed in my machine and to my surprise it was working fine allowing me to connect to the FTP location. From this I could infer that the problem was with the way SSIS or the WinSCP command line is handling the credentials.&lt;/div&gt;
&lt;div&gt;
I did some detailed analysis on the command used for FTP operation by WinSCP which was as below&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;open ftp://username&lt;username&gt;:password&lt;password&gt;@Servername&lt;ftpservername&gt;:Port&lt;portnumber&gt;&lt;/portnumber&gt;&lt;/ftpservername&gt;&lt;/password&gt;&lt;/username&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
And managed to find the issue. The problem in this case was the password which contains special characters like&amp;nbsp;+. This will break in case of the WinSCP.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Solution&lt;/h2&gt;
&lt;div&gt;
The solution in the above case was to encode the special characters before being passed to the url. If you&#39;ve used .NET programming before you should know that there&#39;s a function available in .NET&amp;nbsp;&lt;span style=&quot;background-color: #f2f2f2;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-weight: bold;&quot;&gt;EscapeDataString&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;which is available in System.Uri namespace. This function provides with the encoded values when special character is passed.&lt;/div&gt;
&lt;div&gt;
Based on this we can develop a solution such as below for handling the above scenario.&lt;/div&gt;
&lt;div&gt;
Create a function which will parse through the passed URL string and looks for special characters within it. Once found it will pass the character to the EscapeDataString function which will return the encoded value corresponding to it.&lt;br /&gt;
The string parsing can be done using RegexMatch function to find out the special characters.&lt;br /&gt;
So the overall package would look like this&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJiG8W6yLT7Jf_Hy9G7MBvIwRhV8qEsmsvm2vq6i2Xu-NkKl17sbfJ0mghp5nosNqOBqVpaFMPdv51bkcXsrGViV84vTjE8ryasI9I1R4g5NIUe1t8DOf1Vl6GQ-QdsrstiVjdZTMqEf2a/s1600/FTP.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;293&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJiG8W6yLT7Jf_Hy9G7MBvIwRhV8qEsmsvm2vq6i2Xu-NkKl17sbfJ0mghp5nosNqOBqVpaFMPdv51bkcXsrGViV84vTjE8ryasI9I1R4g5NIUe1t8DOf1Vl6GQ-QdsrstiVjdZTMqEf2a/s400/FTP.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
The Script task will receive as parameter the URL for FTP/SFTP and then parse it for encoding the special characters as below&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;public void Main()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var str = EncodeUrl(Dts.Variables[&quot;Url&quot;].Value.ToString());&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;Dts.Variables[&quot;EncodedUrl&quot;].Value = str;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Dts.TaskResult = (int)ScriptResults.Success;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; private static string EncodeUrl(string URLInput)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; const string pattern = &quot;[$&amp;amp;+,/:;=?@]&quot;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var match = Regex.Match(toEncode, pattern);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; while (match.Success)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;URLInput&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;URLInput&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;.Replace(match.Value, Uri.EscapeDataString(match.Value));&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; match = Regex.Match(&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;URLInput&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;, pattern);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;URLInput&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Once the encoded URL is returned by the above function you can then store it in a variable and use it to set expression properties for your Execute Process Task to use the returned value.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
In the above code you need to add a reference to System.Text.RegularExpressions namespace &amp;nbsp;before using the Regex.Match function. Uri.EscapeDataString comes under System.Data namespace which will be included by default inside the script task.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
In the above case function will replace character&amp;nbsp;+ with its encoded value&amp;nbsp;%2B which will work well with the WinSCP.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Conclusion&lt;/h2&gt;
&lt;div&gt;
As discussed above the special characters in credentials have to be encoded before generating the URL for FTP in case of applications like WinSCP.&lt;br /&gt;
The above illustration gives an easier way of doing it within the SSIS package using a simple .NET function which can be invoked from within a simple script task.&lt;br /&gt;
Hope this helps to solve similar issues faced due to the presence of special characters in URLs and in query string parameter values.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</description><link>http://visakhm.blogspot.com/2016/10/winscp-tips-passing-credentials-with.html</link><author>noreply@blogger.com (Visakh Murukesan)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjL2U8vzIlt7iU_SzAj6plqNH0NHlULStVbmQ4Q7O7hW-tjdNJmMAWUt3-W8Qpt_Y4qLgVwc8lAgPMUsDdPHSTEceuFTWaaMxie9V_CJxO0dEBrO_8Shdu2cB0uzmdWCHievmSf6y7NqZg8/s72-c/FTP.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7998687752365941655.post-6468359173565021731</guid><pubDate>Fri, 26 Aug 2016 08:42:00 +0000</pubDate><atom:updated>2016-08-26T14:12:08.386+05:30</atom:updated><title>SSRS Tips : Fixing Format Issues in MHTML Rendered SSRS Reports </title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Impetus&lt;/h2&gt;
&lt;div&gt;
The impetus for writing this blog came from a recent issue I faced while setting up email based subscription for one of my MIS reports for enterprise wide distribution. The report content had to be embedded within the email in HTML format so I had set the rendering option as MHTML for the subscription. When report is delivered using subscription it can be noticed that none of the formatting, cosmetic settings on the original report gets applied.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
This article explains how you can overcome this issue to preserve the native format settings you applied to the report while rendering it through automated subscriptions in MHTML format.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Illustration&lt;/h2&gt;
&lt;div&gt;
Consider the below report created in SSRS&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzkdCEGI5OA802TSxDlZ_Vv5jPhXgRX0o6Fkr61qkbG8Uod0e0gV07nrvqZLO7OZmGqfOjqSUauymKS2BT2B6o2PHoCll3osBrDuwhq7N-2sR2995Wms9wfdSQDMkXnJ2KwxZYVmsIQl3z/s1600/ss.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;283&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzkdCEGI5OA802TSxDlZ_Vv5jPhXgRX0o6Fkr61qkbG8Uod0e0gV07nrvqZLO7OZmGqfOjqSUauymKS2BT2B6o2PHoCll3osBrDuwhq7N-2sR2995Wms9wfdSQDMkXnJ2KwxZYVmsIQl3z/s320/ss.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
The requirement was to schedule an automated delivery of the above report through email to a list of users. The report has to be embedded within the email body rather than being as a separate attachment.&lt;br /&gt;
The best way to implement the above requirement is to set an email based subscription for the report and configure the render format as MHTML. This would ensure that the report will be embedded within the body of the email&lt;br /&gt;
As per the above approach subscription is configured for the report as below&lt;br /&gt;
&lt;br /&gt;
.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjnkhiyViuW4RQn5pQDBUFQJ4R-vNyhhCLIrrs-POXXTY7xNRNk1uhY36uC-Nil_6hz1wgyxbRaPwA_cdNR-BDlQ96C4O17RJJIZ8VZ3v2-ca1aTZjXMDrQdwWjMo00nIAWWnMWkkJcttb-/s1600/ss.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjnkhiyViuW4RQn5pQDBUFQJ4R-vNyhhCLIrrs-POXXTY7xNRNk1uhY36uC-Nil_6hz1wgyxbRaPwA_cdNR-BDlQ96C4O17RJJIZ8VZ3v2-ca1aTZjXMDrQdwWjMo00nIAWWnMWkkJcttb-/s400/ss.png&quot; width=&quot;357&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
When the subscription got triggered the email obtained was as below&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGGwtu_oh8MsluFZGxY2rQWwkydzIahUeP1FuatmB80WhSeCZRtVfl13guRKFd5zgCOZzrSAwSSKaQ93YaUQ8-ZXYNXe8O957EDrdsGMr5WQiVQcNRNyJSibYBNRv_9LezlHtcj2Ya97fT/s1600/ss.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;370&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGGwtu_oh8MsluFZGxY2rQWwkydzIahUeP1FuatmB80WhSeCZRtVfl13guRKFd5zgCOZzrSAwSSKaQ93YaUQ8-ZXYNXe8O957EDrdsGMr5WQiVQcNRNyJSibYBNRv_9LezlHtcj2Ya97fT/s400/ss.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
As you see from the above, the rendered report was stripped off its format settings when rendered in MHTML format&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
This would cause difficulty in interpreting the report especially when amount of data shown in the report is huge. Question was how to make sure the format remains intact while rendering through sunscription as above&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
I was able to arrive at the solution after some analysis. The solution is to use expression mode to set the format properties for the report cells&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
As an example see the below illustration&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimSu4bEdnclaxU08f0TwZWrPzVbP-TLE_iEwKQmKuHMnG4xtoUG37oeYCQpWIPtXZqUheOo-pEBMvGBzyuwdKdt-tmfF55PTC0S-czu53HlhjCjNLSxPCvSBNZnAo5AjqlxjAt2dCi_cSL/s1600/ss.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;76&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimSu4bEdnclaxU08f0TwZWrPzVbP-TLE_iEwKQmKuHMnG4xtoUG37oeYCQpWIPtXZqUheOo-pEBMvGBzyuwdKdt-tmfF55PTC0S-czu53HlhjCjNLSxPCvSBNZnAo5AjqlxjAt2dCi_cSL/s640/ss.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Once you set this as an expression and set it for subscription you can see the rendered report as below&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOehLPzkK1ioKp30xvDCcRXOFh_CtsfYshSbR19gqmwJlrzvqFMNlcLB6QoturmShYY-4EunFgebwoM9Ab-oFSQVj_e-NmSAY_wjRzwKualJb2B7m8nfkwoRezuMJqjWO6JDvIchxIisDj/s1600/ss.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;306&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOehLPzkK1ioKp30xvDCcRXOFh_CtsfYshSbR19gqmwJlrzvqFMNlcLB6QoturmShYY-4EunFgebwoM9Ab-oFSQVj_e-NmSAY_wjRzwKualJb2B7m8nfkwoRezuMJqjWO6JDvIchxIisDj/s320/ss.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
As you see from the above the report gets rendered with all the format settings correctly applied. All the property values have been set using expressions in the report designer and MHTML format will preserve the values while rendering through the subscription.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2 style=&quot;clear: both; text-align: left;&quot;&gt;
Conclusion&lt;/h2&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
As seen from the illustration above, the format properties of the report can be preserved intact by using expressions while rendering in MHTML format.&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</description><link>http://visakhm.blogspot.com/2016/08/ssrs-tips-fixing-format-issues-in-mhtml.html</link><author>noreply@blogger.com (Visakh Murukesan)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzkdCEGI5OA802TSxDlZ_Vv5jPhXgRX0o6Fkr61qkbG8Uod0e0gV07nrvqZLO7OZmGqfOjqSUauymKS2BT2B6o2PHoCll3osBrDuwhq7N-2sR2995Wms9wfdSQDMkXnJ2KwxZYVmsIQl3z/s72-c/ss.png" height="72" width="72"/><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7998687752365941655.post-8303287083411913285</guid><pubDate>Tue, 02 Aug 2016 06:04:00 +0000</pubDate><atom:updated>2016-08-02T11:34:05.638+05:30</atom:updated><title>What&#39;s New in SQL 2016 - Temporal Tables</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Introduction&lt;/h2&gt;
Most of us are familiar with CDC tables in SQL Server. CDC or Change Data Capture is used to track and capture the DML changes happening in a table and makes use of log entries for capturing the information. SQL 2016 provides similar kind of functionality for capturing the history of the data related to memory optimized tables. These historical data capturing feature is referred to as &lt;b&gt;Temporal Tables.&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
Memory&amp;nbsp;&lt;b&gt;&amp;nbsp;&lt;/b&gt;Optimized Tables were introduced in SQLServer 2014 and they provide an efficient way to store and manipulate data using natively compiled procedures, They provide two levels of durability Schema Only and Schema and Data. Schema Only will only make sure schema is preserved in case of a server restart whereas in the latter case both the schema as well as the data is persisted as in the case of a normal table (disk based).&lt;br /&gt;
Temporal tables are only supported in the case where durability option is set to schema and data. These tables will be persisted to disk along with data. When we created a temporal table it will preserve the history and will provide data easily based on our point in time analysis.&lt;br /&gt;
The temporal tables makes use of a history table internally to track the history of data changes happening in the memory optimized table. The main table will have two datetime2 type fields which are referred to as period columns. This is used by the table to determine the validity of each record to provide an effective point in time analysis. The date fields determine the validity of a record ie period for which record is(was) valid&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;
Illustration&lt;/h2&gt;
&lt;div&gt;
Consider the below case where we have a database to which we are going to add a memory optimized table and make it a temporal table.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
For creating a memory optimized table we need to first have a file group in the database that supports memory optimized data. This can be done by using a series of ALTER DATABASE statements as shown below (Assumption is that SQL2016LocalTest is an already existing database in your SQLServer instance)&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;ALTER DATABASE [SQL2016LocalTest] ADD FILEGROUP mem_opt CONTAINS MEMORY_OPTIMIZED_DATA &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;ALTER DATABASE [SQL2016LocalTest] ADD FILE (name=&#39;mem_opt1&#39;, filename=&#39;&lt;file path=&quot;&quot;&gt;&#39;) TO FILEGROUP mem_opt &amp;nbsp;&amp;nbsp;&lt;/file&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;ALTER DATABASE [SQL2016LocalTest] SET MEMORY_OPTIMIZED_ELEVATE_TO_SNAPSHOT=ON &amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;GO &amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;br /&gt;
Once the filegroup is setup as above we shall create the memory optimized table on it using CREATE TABLE statement as below&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;CREATE TABLE dbo.HotelBooking&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;BookingID int,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;RoomNo int,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;CustomerName varchar(100),&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;BookingDate datetime,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;ValidFrom datetime2 &amp;nbsp;generated always as row start not null default (&#39;19000101&#39;),&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;ValidTo datetime2 &amp;nbsp; &amp;nbsp;generated always as row end not null default (&#39;99991231&#39;),&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;PRIMARY KEY CLUSTERED (BookingID),&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;period for system_time(ValidFrom, ValidTo)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp;WITH (SYSTEM_VERSIONING = ON (HISTORY_TABLE = dbo.BookingHistory));&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
Once the above statement is executed we will have a temporal table setup with an internal history table which will used for tracking the history of data from the main table.&lt;br /&gt;
You can check this by expanding tables under the corresponding databases node to see the tables as per below&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmbyBsGodkB-wM-zo7ubiTbubQZmPnnjulXQXyqZ1Z2TzTcdMx4xTkMO-H5vaYxDpBKXN8LERa44AFoaqyuV_KUm3vezRJUwsoEtrp3nXeqbE_K-eVhPxGRVW5ezpd2eDFqqdtUJz_PoA-/s1600/ss.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;223&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmbyBsGodkB-wM-zo7ubiTbubQZmPnnjulXQXyqZ1Z2TzTcdMx4xTkMO-H5vaYxDpBKXN8LERa44AFoaqyuV_KUm3vezRJUwsoEtrp3nXeqbE_K-eVhPxGRVW5ezpd2eDFqqdtUJz_PoA-/s320/ss.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
As you see the table will be represented with a small clock icon indicating that it is a temporal table and will also have the history table specified under it. The history table will be an exact replica of the main table in schema and will have clustered index on the key column.&lt;br /&gt;
Now lets insert some data to this table. For evaluating the history capture its best if you do the data manipulation operation over a period of time.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;INSERT dbo.HotelBooking&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;BookingID,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;RoomNo,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;CustomerName,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;BookingDate&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;VALUES&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;1001,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;101,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&#39;Peter&#39;,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&#39;20150923&#39;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;UPDATE dbo.HotelBooking&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SET CustomerName = &#39;Ramu&#39;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;WHERE RoomNo = 101&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;INSERT dbo.HotelBooking&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;BookingID,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;RoomNo,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;CustomerName,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;BookingDate&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;VALUES&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;1002,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;115,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&#39;John&#39;,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&#39;20160314&#39;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;INSERT dbo.HotelBooking&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;BookingID,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;RoomNo,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;CustomerName,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;BookingDate&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;VALUES&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;1005,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;212,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&#39;Mary&#39;,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&#39;20160416&#39;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;UPDATE&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;dbo.HotelBooking&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SET BookingDate = &#39;20160420&#39;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;WHERE BookingID = 1005&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;INSERT dbo.HotelBooking&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;BookingID,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;RoomNo,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;CustomerName,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;BookingDate&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;VALUES&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;1011,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;307,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&#39;Khader&#39;,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&#39;20160617&#39;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;UPDATE dbo.HotelBooking&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SET CustomerName = &#39;Michelle&#39;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;WHERE RoomNo = 101&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;INSERT dbo.HotelBooking&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;BookingID,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;RoomNo,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;CustomerName,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;BookingDate&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;VALUES&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;1015,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;115,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&#39;Mohsin&#39;,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&#39;20160622&#39;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;DELETE FROM&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;dbo.HotelBooking&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;WHERE BookingID = 1002&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
Once you&#39;ve done the above data addition/modification you can check the main and history table and you will get the below data snapshot&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZlxYh36uJBQ9wNb2nJHbtcjIzSve5rN8oNNEp1BalsVDh1x6stLaLF4SQzunw23EVw9xVdHnrmAOs3bTI0wW88f_yOsQ7i0O7VMpszJ3ZasgFnd3Q0kmXmVRFjY8-2NeE84YvRlZlLorL/s1600/ss.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;344&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZlxYh36uJBQ9wNb2nJHbtcjIzSve5rN8oNNEp1BalsVDh1x6stLaLF4SQzunw23EVw9xVdHnrmAOs3bTI0wW88f_yOsQ7i0O7VMpszJ3ZasgFnd3Q0kmXmVRFjY8-2NeE84YvRlZlLorL/s640/ss.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I have done the data modification over a period of time (around 2 days) to indicate the effect on history table.&lt;br /&gt;
If you analyze the above data you can see how the progression of data is getting captured in the history&lt;br /&gt;
Everytime a new &lt;b&gt;insert &lt;/b&gt;happens it will be captured in the main table HotelBooking with ValidFrom set to the corresponding system time and ValidTo set to the maxdate value (9999-12-31 23:59:59.99999)&lt;br /&gt;
Similarly every &lt;b&gt;update &lt;/b&gt;operation is carried out by means of two internal operations a delete of the old entry followed by insertion of new entry. This can be seen from resultset above where you will have an entry in both the tables (see records with BookingID 1001 and 1005 in the above case). The history table will have the entry with the values prior to the modification with ValidFrom as actual ValidFrom value from the main entry and ValidTo as the corresponding system time. The main table entry will have the modified values with ValidFrom as the corresponding system time and ValidTo as the max date value.&lt;br /&gt;
In the case of &lt;b&gt;delete &lt;/b&gt;operations the record will be removed from the main table and there will be an entry added to the history table with ValidFrom as the original ValidFrom and ValidTo as the corresponding system time.&lt;br /&gt;
Now that we have got an idea of what happens on the background and how data will get captured in the two tables lets now see some functions which are associated to Temporal tables and which will help us to query temporal data for time based analysis.&lt;br /&gt;
&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
AS OF time&lt;/h4&gt;
AS OF time function gives the snapshot of temporal table data at an instant of time i.e the data that is valid at that instance&lt;br /&gt;
&lt;br /&gt;
Lets try it on our sample table and illustration is below&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SELECT * FROM dbo.HotelBooking FOR SYSTEM_TIME AS OF &#39;2016-07-25 05:15&#39;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMT_TkoxrFVoq6uL4fmVPsndBJTDMpaYJ6UTIsxiVWECXc7ZcYU0bwKtXPsmzVU87rKAmjdhT3Fbml9TgmVL_50uat-oeyfDG2py27dQ-bDiFBP1OdFwHJr9TBoLvS0yzvCPiS_0cWLKc_/s1600/ss.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;394&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMT_TkoxrFVoq6uL4fmVPsndBJTDMpaYJ6UTIsxiVWECXc7ZcYU0bwKtXPsmzVU87rKAmjdhT3Fbml9TgmVL_50uat-oeyfDG2py27dQ-bDiFBP1OdFwHJr9TBoLvS0yzvCPiS_0cWLKc_/s640/ss.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Now see the last resultset and compare it with the original table vs history entries and you will notice that there are only 3 entries in the resultset.&lt;br /&gt;
If you check the ValidFrom and ValidTo values for the resultset entries its pretty evident that those were the entries which were valid as on specified snapshot time (ie ValidFrom &amp;lt; 2016-07-25 05:15 &amp;lt; ValidTo)&lt;br /&gt;
&amp;nbsp;The ignored records were those which were either expired before snapshot date (ex: 1001 Peter) or the ones which became valid after the snapshot time (ex: 1015,1011)&lt;br /&gt;
So effectively what AS OF function does is to apply a query logic as below&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SELECT * FROM dbo.HotelBooking WHERE &#39;2016-07-25 05:15&#39; BETWEEN ValidFrom &amp;nbsp;AND ValidTo&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;UNION ALL&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SELECT * FROM dbo.BookingHistory WHERE &#39;2016-07-25 05:15&#39; BETWEEN ValidFrom &amp;nbsp;AND ValidTo &amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Execute this and you will get the same resultset as returned by AS OF&lt;br /&gt;
&lt;br /&gt;
Graphically this can be depicted using the three scenarios as shown below&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIRJytYexJcQ2iQuUd0XQlYzFUtOeKya_WH-xbQy1RR7hbjhRWVQS2sJLiwepBKIaiQGG0P1tlosZGeOXv-YrUnAn1UeY9M54RMuLCy7J0pjqmumSuzaxSt806EbRtSvCVAMR2WauJ2wDW/s1600/Temporal.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;259&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIRJytYexJcQ2iQuUd0XQlYzFUtOeKya_WH-xbQy1RR7hbjhRWVQS2sJLiwepBKIaiQGG0P1tlosZGeOXv-YrUnAn1UeY9M54RMuLCy7J0pjqmumSuzaxSt806EbRtSvCVAMR2WauJ2wDW/s320/Temporal.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
FROM time1 TO time2&lt;/h4&gt;
&lt;div&gt;
FROM time1 TO time2 function returns all records whose validity overlaps the period specified by time1 to time2.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
The illustration for this can be shown as below&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SELECT * FROM dbo.HotelBooking FOR SYSTEM_TIME &amp;nbsp;FROM &#39;2016-07-24 10:34&#39; TO &#39;2016-07-25 05:16:55.4510553&#39;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipETytEh8tkXwjVgsGbcGQgvClvHVOYjfOBvRPDnPMeHLRwpWVwhQ4HRtoZdwVDzpkxMfGKY1Yu0w9SfNHyowkV6Kyoj4H3m2bQtGYSv1Ok7jgwfI7snZodvfRiD58EwnKhzXsWnyaeFOc/s1600/ss.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;382&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipETytEh8tkXwjVgsGbcGQgvClvHVOYjfOBvRPDnPMeHLRwpWVwhQ4HRtoZdwVDzpkxMfGKY1Yu0w9SfNHyowkV6Kyoj4H3m2bQtGYSv1Ok7jgwfI7snZodvfRiD58EwnKhzXsWnyaeFOc/s640/ss.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
The resultset in this consists of all records with the interval ValidFrom to ValidTo overlapping between interval specified by time1 and time2. One thing to note here is that record with BookingID 1011 was not included as it became valid only from the end boundary value whereas function considers only the cases where interval starts or ends &lt;b&gt;within &lt;/b&gt;the boundary value ie the equivalent query can be written as&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SELECT * FROM dbo.HotelBooking WHERE &amp;nbsp; ValidFrom &amp;lt; &#39;2016-07-25 05:16:55.4510553&#39; AND ValidTo &amp;gt; &#39;2016-07-24 10:34&#39;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;UNION ALL&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SELECT * FROM dbo.BookingHistory WHERE &amp;nbsp; &amp;nbsp;ValidFrom &amp;lt; &#39;2016-07-25 05:16:55.4510553&#39; AND ValidTo &amp;gt; &#39;2016-07-24 10:34&#39;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
The corresponding scenarios can be represented graphically as below&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQzDrA8TfsMhk4WsCjVmEXBcKR0TWeAyWVkWSXNu9cUQSyhPU4tXviI8937LMhyphenhyphen-RloMO7USG4RNodas7EYOL6eXHyLkuK5fIxpu1eS6ICSjFHyThD4stKQSBGQ2syTg8xiibGn4km-yjj/s1600/Temporal.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;284&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQzDrA8TfsMhk4WsCjVmEXBcKR0TWeAyWVkWSXNu9cUQSyhPU4tXviI8937LMhyphenhyphen-RloMO7USG4RNodas7EYOL6eXHyLkuK5fIxpu1eS6ICSjFHyThD4stKQSBGQ2syTg8xiibGn4km-yjj/s320/Temporal.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
BETWEEN time1 AND time2&lt;/h4&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
BETWEEN function works quite similar to the FROM function to get the resultset where record interval of ValidFrom to ValidTo &amp;nbsp;overlaps with the interval specified by time1 to time2. The only difference between BETWEEN and FROM is that BETWEEN considers the end boundary value (time2) also as a part of the interval unlike the FROM function.&lt;/div&gt;
&lt;div&gt;
So if you see the illustration for BETWEEN it looks like below&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SELECT * FROM dbo.HotelBooking FOR SYSTEM_TIME &amp;nbsp;BETWEEN &#39;2016-07-24 10:34&#39; AND &#39;2016-07-25 05:16:55.4510553&#39;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwzbFUjIHKkgJDUKtovci0ANg4Tvo5yul6EZIzlyGSGE-62Ww7fe4YEgbdfpZBkRT1sP_xHwJFXuiPnas61eU5T3Gc4K-jX2DnUZkdFAwqqjtrlOnfS8a6plgq3c-HuXWeoh8rEe-C21lo/s1600/ss.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;342&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwzbFUjIHKkgJDUKtovci0ANg4Tvo5yul6EZIzlyGSGE-62Ww7fe4YEgbdfpZBkRT1sP_xHwJFXuiPnas61eU5T3Gc4K-jX2DnUZkdFAwqqjtrlOnfS8a6plgq3c-HuXWeoh8rEe-C21lo/s640/ss.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
Check the result and you can see that its very much similar to resultset for FROM with only addition being the record with BookingID 1011 which starts at the same time as the end time of the interval&lt;br /&gt;
So equivalent query in this case can be given as&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SELECT * FROM dbo.HotelBooking WHERE &amp;nbsp; ValidFrom &amp;lt;= &#39;2016-07-25 05:16:55.4510553&#39; AND ValidTo &amp;gt; &#39;2016-07-24 10:34&#39;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;UNION ALL&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SELECT * FROM dbo.BookingHistory WHERE &amp;nbsp; &amp;nbsp;ValidFrom &amp;lt;= &#39;2016-07-25 05:16:55.4510553&#39; AND ValidTo &amp;gt; &#39;2016-07-24 10:34&#39;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;ORDER BY ValidFrom&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
Corresponding graphical representation is shown below&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjynKv-X9_j_pfOygF9LybrpwCySppKhGRF5dXNlsLYuDkLVz0OCqaNiA5o7hMu_ckyK9z3R5HsNDq6rk6fKrC0nzZ3x9XWE-FuGzcKpVhDdbFrGe3aGCc6TrEAE3loHUvLtxr1-fGB5irC/s1600/Temporal.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;360&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjynKv-X9_j_pfOygF9LybrpwCySppKhGRF5dXNlsLYuDkLVz0OCqaNiA5o7hMu_ckyK9z3R5HsNDq6rk6fKrC0nzZ3x9XWE-FuGzcKpVhDdbFrGe3aGCc6TrEAE3loHUvLtxr1-fGB5irC/s640/Temporal.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
CONTAINED IN (time1,time2)&lt;/h4&gt;
&lt;div&gt;
CONTAINED IN function returns a resultset where the record validity &lt;b&gt;falls within&lt;/b&gt; the interval from time1 to time2 ie ValidFrom and ValidTo both lying within the interval&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Illustration is given below&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SELECT * FROM dbo.HotelBooking FOR SYSTEM_TIME &amp;nbsp;CONTAINED IN ( &#39;2016-07-24 10:32&#39;,&#39;2016-07-25 05:18:35.3157322&#39;) ORDER BY ValidFrom&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsMHVCNxaY003_kscEOqW-1rTwBPI2WdzAYWCrTzhw1Vap9qKaH_WOX5cw9WAoajiXr0TdTrS2j1bmV15y2GSyMGI0_MsWCH6uyOorDt_7dnJyHT0ZTkYkB19hPbszLK0W2RQoVVH4kQ-H/s1600/ss.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;352&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsMHVCNxaY003_kscEOqW-1rTwBPI2WdzAYWCrTzhw1Vap9qKaH_WOX5cw9WAoajiXr0TdTrS2j1bmV15y2GSyMGI0_MsWCH6uyOorDt_7dnJyHT0ZTkYkB19hPbszLK0W2RQoVVH4kQ-H/s640/ss.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
The resultset on analysis reveals that only those records whose validity &lt;b&gt;falls fully within the interval&lt;/b&gt; time1 to time2 are returned by CONTAINED IN function.&lt;br /&gt;
&lt;br /&gt;
The equivalent query is as below&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SELECT * FROM dbo.HotelBooking WHERE ValidFrom &amp;gt;= &#39;2016-07-24 10:32&#39; AND ValidTo &amp;lt;= &#39;2016-07-25 05:18:35.3157322&#39;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;UNION ALL&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SELECT * FROM dbo.BookingHistory WHERE ValidFrom &amp;gt;= &#39;2016-07-24 10:32&#39; AND ValidTo &amp;lt;= &#39;2016-07-25 05:18:35.3157322&#39; ORDER BY ValidFrom&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
Graphically this can be represented as below&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBG8VfX3oeaWoIT1s8J1xjKzgjtuzkW2j6UmCVrBghEVZ40ZFg5r85pFlxRFLywN-xJeJ-JywW__iGEQ_u7aLYO-DSwCoLw1MF8iIT-oHRNrTXkwGPOTlF3MyCFIFY4gBISQ0eD_CZy4u5/s1600/Temporal.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;360&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBG8VfX3oeaWoIT1s8J1xjKzgjtuzkW2j6UmCVrBghEVZ40ZFg5r85pFlxRFLywN-xJeJ-JywW__iGEQ_u7aLYO-DSwCoLw1MF8iIT-oHRNrTXkwGPOTlF3MyCFIFY4gBISQ0eD_CZy4u5/s640/Temporal.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
ALL&lt;/h4&gt;
&lt;br /&gt;
The ALL function simply combines the results from both the main and history table in the resultset&lt;br /&gt;
&lt;br /&gt;
Illustration below&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SELECT * FROM dbo.HotelBooking FOR SYSTEM_TIME ALL &amp;nbsp; ORDER BY ValidFrom&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiO2XputBHN_-uxqGux4u6XF4FMYy7AtZvQsmmyNIpwErKlGagfOfskiITDljDJe4OCjz-xTqHGGyQkw70zPh_zUbedmZIca_eexivCt7sMh6j9c91Cw_xaeQCC3NU7YGvtoq6rjuMz69-A/s1600/ss.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;498&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiO2XputBHN_-uxqGux4u6XF4FMYy7AtZvQsmmyNIpwErKlGagfOfskiITDljDJe4OCjz-xTqHGGyQkw70zPh_zUbedmZIca_eexivCt7sMh6j9c91Cw_xaeQCC3NU7YGvtoq6rjuMz69-A/s640/ss.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
The resultset includes all records from both the tables&lt;br /&gt;
&lt;br /&gt;
The equivalent query is as below&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SELECT * FROM dbo.HotelBooking&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;UNION ALL&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SELECT * FROM dbo.BookingHistory &amp;nbsp;ORDER BY ValidFrom&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;
See the corresponding graphical representation below&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjd1GKJA_b7SzN0sB_U8WQKrdLJ3K4Pv9R_HspChdEGC6ohxA9tkz48r2wUMqLMSlm94tnyWcADx7WcaEWc6rWUGx4b2Zvbt5d1JaIPBqjohn1qMtPbn_AifhyphenhyphenmGb9gH7cKnNtEpYSXfsiM/s1600/Temporal.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;360&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjd1GKJA_b7SzN0sB_U8WQKrdLJ3K4Pv9R_HspChdEGC6ohxA9tkz48r2wUMqLMSlm94tnyWcADx7WcaEWc6rWUGx4b2Zvbt5d1JaIPBqjohn1qMtPbn_AifhyphenhyphenmGb9gH7cKnNtEpYSXfsiM/s640/Temporal.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Conclusion&lt;/h2&gt;
&lt;/div&gt;
&lt;div&gt;
The above illustrations gives a clear idea about how temporal functions can be used to generate time based results from a temporal table.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
This shows that Temporal tables provide a much convenient way of capturing history and using it for effective time based analysis&lt;br /&gt;
Hope you this article was informative enough. Feel free to revert with any comments you may have.&lt;/div&gt;
&lt;/div&gt;
</description><link>http://visakhm.blogspot.com/2016/08/whats-new-in-sql-2016-temporal-tables.html</link><author>noreply@blogger.com (Visakh Murukesan)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmbyBsGodkB-wM-zo7ubiTbubQZmPnnjulXQXyqZ1Z2TzTcdMx4xTkMO-H5vaYxDpBKXN8LERa44AFoaqyuV_KUm3vezRJUwsoEtrp3nXeqbE_K-eVhPxGRVW5ezpd2eDFqqdtUJz_PoA-/s72-c/ss.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7998687752365941655.post-4831675768150881300</guid><pubDate>Wed, 13 Jul 2016 17:01:00 +0000</pubDate><atom:updated>2016-07-13T22:31:05.186+05:30</atom:updated><title>Whats New in SQL 2016 - Native JSON Function Support - Performing Data Manipulations in JSON Documents</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
This is the last and the final article in the series which discusses on the native JSON support in SQL 2016.&lt;br /&gt;
Previously I had blogged on how JSON documents can be generated from relational data using FOR JSON construct here&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://visakhm.blogspot.ae/2016/06/whats-new-in-sql-2016-native-json.html&quot;&gt;http://visakhm.blogspot.ae/2016/06/whats-new-in-sql-2016-native-json.html&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
and also how JSON documents can be parsed and relational data can shred from them using OPENJSON here&lt;br /&gt;
&lt;a href=&quot;http://visakhm.blogspot.ae/2016/07/whats-new-in-sql-2016-native-json.html&quot;&gt;http://visakhm.blogspot.ae/2016/07/whats-new-in-sql-2016-native-json.html&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
The article explains on some of the JSON functions which is available in Transact SQL &amp;nbsp;and can be utilized for manipulating the data within JSON documents.&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
ISJSON()&lt;/h2&gt;
&lt;div&gt;
The ISJSON function is used to check if a document passed has a valid JSON data. It accepts an expression which would be a string and validates if it contains aproper JSON data. The return value would be a boolean result (1 or 0) based on whether the string contains a valid JSON result or not.&lt;/div&gt;
&lt;div&gt;
Lets see the small illustration below to understand the ISJSON function&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;declare @x nvarchar(max)=&#39;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &quot;Items&quot;: [&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemID&quot;: 101,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;Monitor CRT 18\&quot;&quot;,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Unitprice&quot;: 200&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; },&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemID&quot;: 110,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;Printer Catridge&quot;,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Unitprice&quot;: 112&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; },&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemID&quot;: 112,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;Copier Ink&quot;,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Unitprice&quot;: 20&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; },&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemID&quot;: 123,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;Wireless Mouse&quot;,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Unitprice&quot;: 30&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; ]&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;}&#39;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SELECT ISJSON(@x)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
The result will be 1 as&amp;nbsp;@x contains valid JSON data&lt;br /&gt;
&lt;br /&gt;
If at all the passed document can be considered as a valid JSON, ISJSON function returns 1 as seen from the below examples&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SELECT *&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;FROM&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;VALUES (&#39;{}&#39;),(&#39;[]&#39;),(&#39;{&quot;item&quot;:1}&#39;),(&#39;{&quot;q&quot;:[1]}&#39;),(&#39;[0,1,2]&#39;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;)t(v)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;WHERE ISJSON(v)=1&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
and the result&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjUehrbok3kDaR1w0MT2Z2RxE6BRo22VvUvMcpGQSDhqdwowNJF4R8rFWl7eln4AEGiDcylpuK__YFuG6XQjmASxBV8eSQgcA9DiV3b5ZrY9eroaWmh3Qp6cf1TtbvpQrwHlz3394Gr1UW/s1600/ss.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjUehrbok3kDaR1w0MT2Z2RxE6BRo22VvUvMcpGQSDhqdwowNJF4R8rFWl7eln4AEGiDcylpuK__YFuG6XQjmASxBV8eSQgcA9DiV3b5ZrY9eroaWmh3Qp6cf1TtbvpQrwHlz3394Gr1UW/s1600/ss.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
The first two values represents blank JSON object and array documents whereas the next three represents JSON document with single object/array object and all of them are valid.&lt;br /&gt;
One more thing you may note from the above illustration is how we can use ISJSON function as a filter condition in the WHERE clause to check for the rows with valid JSON data in the column and then to do some manipulations on them.&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
JSON_VALUE()&lt;/h2&gt;
&lt;div&gt;
JSON_VALUE is another very useful utility function which can be used to parse a JSON document and return a single element value. JSON_VALUE takes as argument a JSON expression and a path and traverses the JSON document as per the path to return a single scalar value.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
Lets see a simple example of how JSON_VALUE can be applied to get values from a JSON document&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;declare @x nvarchar(max)=&#39;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &quot;Item&quot;:&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemID&quot;: 101,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;Monitor CRT 18\&quot;&quot;,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Unitprice&quot;: 200&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;}&#39;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
The above shows a very simple JSON document with a single JSON element having three key value pairs.&lt;br /&gt;
The values from the above JSON document can be parsed out using JSON_VALUE function as per below code&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SELECT JSON_VALUE(@x,&#39;$.Item.ItemID&#39;) AS ItemID,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;JSON_VALUE(@x,&#39;$.Item.ItemDesc&#39;) AS ItemDesc,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;JSON_VALUE(@x,&#39;$.Item.Unitprice&#39;) AS Unitprice&lt;/span&gt;&lt;br /&gt;
The result is as below&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgozRHInBmnxg6G06zIiHIlzxlZ0BgrPdRAwx7_zKeHtBZZz9kKMk7R2pIYkiX4uLFGWkfq4rjAck9BZMGpWUQ67gYo-A1VYa9-ghD3x3pCUY2LCz06UgWUtVB5F5yO9K2gIZBRhauuVH9T/s1600/ss.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgozRHInBmnxg6G06zIiHIlzxlZ0BgrPdRAwx7_zKeHtBZZz9kKMk7R2pIYkiX4uLFGWkfq4rjAck9BZMGpWUQ67gYo-A1VYa9-ghD3x3pCUY2LCz06UgWUtVB5F5yO9K2gIZBRhauuVH9T/s1600/ss.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
This is a simple document with all key values in the same level. Now lets see how we can use JSON_VALUE in the case where JSON document has key values in multiple levels&lt;br /&gt;
&lt;br /&gt;
Consider the below JSON example&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;declare @x nvarchar(max) = &#39;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&quot;Order&quot;: {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderDesc&quot;: &quot;Order 1&quot;,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderDate&quot;: &quot;2013-02-12T00:00:00&quot;,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ShippedDate&quot;: &quot;2013-02-20T00:00:00&quot;,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;WebOrder&quot;: false,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderItems&quot;:&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderQty&quot;: 10,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Item&quot;: {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;Wireless Mouse&quot;,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Unitprice&quot;: 30,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SUbItem&quot;: {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SubItemDesc&quot;: &quot;SP17&quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;}&#39;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Now to get the data from the various levels within the document we can apply JSON_VALUE function as per below&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SELECT JSON_VALUE(@x,&#39;$.Order.OrderDesc&#39;) AS OrderDesc,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_VALUE(@x,&#39;$.Order.OrderDate&#39;) AS OrderDate,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_VALUE(@x,&#39;$.Order.ShippedDate&#39;) AS ShippedDate,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_VALUE(@x,&#39;$.Order.WebOrder&#39;) AS WebOrder,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_VALUE(@x,&#39;$.Order.OrderItems.OrderQty&#39;) AS OrderQty,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_VALUE(@x,&#39;$.Order.OrderItems.Item.ItemDesc&#39;) AS ItemDesc,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_VALUE(@x,&#39;$.Order.OrderItems.Item.Unitprice&#39;) AS Unitprice,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_VALUE(@x,&#39;$.Order.OrderItems.Item.SUbItem.SubItemDesc&#39;) AS SubItemDesc&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
The corresponding result is given below&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgduZReolVBX1hRRtGYbsTQALs49GQdpWdzWWslqPuFcwXUvGtzSN0PJBfFz69BL4cKE747gnT8Xe-kYNu5J8Sxmqaobv0CraaIUqmq6S7bmoHGqY8Zjxmy_T23RSuW1YKG234UPGogPye7/s1600/ss.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;38&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgduZReolVBX1hRRtGYbsTQALs49GQdpWdzWWslqPuFcwXUvGtzSN0PJBfFz69BL4cKE747gnT8Xe-kYNu5J8Sxmqaobv0CraaIUqmq6S7bmoHGqY8Zjxmy_T23RSuW1YKG234UPGogPye7/s640/ss.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
One thing to note here is that JSON_VALUE can return only a scalar value from within a single key value pair in the JSON data. So in case you&#39;re referring to a JSON array object which includes multiple key value pairs as per the path specified it will return NULL under the default mode.&lt;br /&gt;
This can be illustrated using the below example&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;declare @x nvarchar(max) = &#39;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &quot;Order&quot;:&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderDesc&quot;: &quot;Order 1&quot;,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderDate&quot;: &quot;2013-02-12T00:00:00&quot;,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ShippedDate&quot;: &quot;2013-02-20T00:00:00&quot;,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;WebOrder&quot;: false,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderItems&quot;:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderQty&quot;: 10,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Item&quot;: [&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;Wireless Mouse&quot;,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Unitprice&quot;: 30,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SUbItem&quot;: [&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SubItemDesc&quot;: &quot;SP17&quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; },&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt; &amp;nbsp;&quot;SubItemDesc&quot;: &quot;SP22&quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp; &amp;nbsp; ]&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; },&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;Monitor&quot;,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Unitprice&quot;: 22,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SUbItem&quot;: [&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SubItemDesc&quot;: &quot;SP27&quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;]&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;]&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;}&#39;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SELECT JSON_VALUE(@x,&#39;$.Order.OrderDesc&#39;) AS OrderDesc,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_VALUE(@x,&#39;$.Order.OrderDate&#39;) AS OrderDate,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_VALUE(@x,&#39;$.Order.ShippedDate&#39;) AS ShippedDate,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_VALUE(@x,&#39;$.Order.WebOrder&#39;) AS WebOrder,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_VALUE(@x,&#39;$.Order.OrderItems.OrderQty&#39;) AS OrderQty,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_VALUE(@x,&#39;$.Order.OrderItems.Item.ItemDesc&#39;) AS ItemDesc,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_VALUE(@x,&#39;$.Order.OrderItems.Item.Unitprice&#39;) AS Unitprice,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_VALUE(@x,&#39;$.Order.OrderItems.Item.SUbItem.SubItemDesc&#39;) AS SubItemDesc&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
If you try the above illustration the result obtained will be something like below&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUFYitKj3R5s3uXhrE1XislNDFcwM5B686OzyfoMDhy5Q65WkIEZUHFtFV3GrvvGeTGKS0Ovqgkgl8E5y_3HCfxO2M_9KQov31mM-MzZmW3QXQAbdb98BenmYtDWn-yRjcJxlybUsTHLFu/s1600/ss.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;40&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUFYitKj3R5s3uXhrE1XislNDFcwM5B686OzyfoMDhy5Q65WkIEZUHFtFV3GrvvGeTGKS0Ovqgkgl8E5y_3HCfxO2M_9KQov31mM-MzZmW3QXQAbdb98BenmYtDWn-yRjcJxlybUsTHLFu/s640/ss.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Analyze the result and you will find that the code is not able to retrieve any keys at the Item and SUbtem level using JSON_VALUE function.&lt;br /&gt;
If you check the JSON document carefully you can see that Item and SUBItem consists of actually an array object (notice the [] around them) rather than a single JSON element. This is why JSON_VALUE cant extract value from them. As previously explained the JSON_VALUE can only extract a single scalar value which is why it fails in the above scenario.&lt;br /&gt;
For the above case if we want to get the values we need to tweak the query as below to get the Item and SUbItem level key values&lt;br /&gt;
&lt;br /&gt;
The modified query would be like this&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SELECT JSON_VALUE(@x,&#39;$.Order.OrderDesc&#39;) AS OrderDesc,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_VALUE(@x,&#39;$.Order.OrderDate&#39;) AS OrderDate,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_VALUE(@x,&#39;$.Order.ShippedDate&#39;) AS ShippedDate,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_VALUE(@x,&#39;$.Order.WebOrder&#39;) AS WebOrder,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_VALUE(@x,&#39;$.Order.OrderItems.OrderQty&#39;) AS OrderQty,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_VALUE(@x,&#39;$.Order.OrderItems.Item[0].ItemDesc&#39;) AS ItemDesc1,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_VALUE(@x,&#39;$.Order.OrderItems.Item[0].Unitprice&#39;) AS Unitprice1,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_VALUE(@x,&#39;$.Order.OrderItems.Item[0].SUbItem[0].SubItemDesc&#39;) AS SubItemDesc11,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_VALUE(@x,&#39;$.Order.OrderItems.Item[0].SUbItem[1].SubItemDesc&#39;) AS SubItemDesc12,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_VALUE(@x,&#39;$.Order.OrderItems.Item[1].ItemDesc&#39;) AS ItemDesc2,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_VALUE(@x,&#39;$.Order.OrderItems.Item[1].Unitprice&#39;) AS Unitprice2,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_VALUE(@x,&#39;$.Order.OrderItems.Item[1].SUbItem[0].SubItemDesc&#39;) AS SubItemDesc21&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
And the result below&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnrhFxFgmLIkJtouxXywWhpW21NuLhl3TBEpWrwJyDqN7JHuhGeSqeqwDUkTXieWrgjz3ToIsuuU4U6WwfnfNlucDJah0HjGuGMNWJiGcsGLaayxScCQq6AqYIqfHkEARc4HDsurF4GPy3/s1600/ss.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;25&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnrhFxFgmLIkJtouxXywWhpW21NuLhl3TBEpWrwJyDqN7JHuhGeSqeqwDUkTXieWrgjz3ToIsuuU4U6WwfnfNlucDJah0HjGuGMNWJiGcsGLaayxScCQq6AqYIqfHkEARc4HDsurF4GPy3/s640/ss.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
But this method is not scalable as we have to be certain on the number of elements at query time to apply the position number based static logic. In such cases we would require logic which will iterate through the JSON elements to return corresponding key values. This will be explained in detail later in this article.&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
strict and lax modes&lt;/h2&gt;
&lt;div&gt;
There are two modes under which the path expression works in the case of JSON functions.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
The default is the &lt;b&gt;lax &lt;/b&gt;mode where the parser doesn&#39;t enforce strict checking for the JSON path specified. In case the path is valid it returns the value as per the path. Otherwise it will return a NULL value. &lt;b&gt;lax &lt;/b&gt;mode being the default option you dont need to explicitly specify it within the path. So all the previous examples uses &lt;b&gt;lax &lt;/b&gt;mode under the hood.&lt;/div&gt;
In contrast &lt;b&gt;strict &lt;/b&gt;mode the JSON path passed is strictly checked against and in case it is an invalid path it returns an error.&lt;br /&gt;
To illustrate this lets use a modified version of the last query in the two modes and see the difference&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;lax mode&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SELECT JSON_VALUE(@x,&#39;lax $.Order.OrderDesc&#39;) AS OrderDesc,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_VALUE(@x,&#39;lax $.Order.OrderDate&#39;) AS OrderDate,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_VALUE(@x,&#39;lax $.Order.ShippedDate&#39;) AS ShippedDate,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_VALUE(@x,&#39;lax $.Order.WebOrder&#39;) AS WebOrder,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_VALUE(@x,&#39;lax $.Order.OrderItems.OrderQty&#39;) AS OrderQty,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_VALUE(@x,&#39;lax $.Order.OrderItems.Item[0].ItemDesc&#39;) AS ItemDesc1,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_VALUE(@x,&#39;lax $.Order.OrderItems.Item[0].Unitprice&#39;) AS Unitprice1,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_VALUE(@x,&#39;lax $.Order.OrderItems.Item[0].SUbItem[0].SubItemDesc&#39;) AS SubItemDesc11,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_VALUE(@x,&#39;lax $.Order.OrderItems.Item[0].SUbItem[1].SubItemDesc&#39;) AS SubItemDesc12&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_VALUE(@x,&#39;lax $.Order.OrderItems.Item[1].ItemDesc&#39;) AS ItemDesc2,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_VALUE(@x,&#39;lax $.Order.OrderItems.Item[1].Unitprice&#39;) AS Unitprice2,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_VALUE(@x,&#39;lax $.Order.OrderItems.Item[1].SUbItem[0].SubItemDesc&#39;) AS SubItemDesc21,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_VALUE(@x,&#39;lax $.Order.OrderItems.Item[1].SUbItem[1].SubItemDesc&#39;) AS SubItemDesc22&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
and the result&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpjxREOUTr2bXQ28GIn9O1UvWS-UrfuxzRZI5CbT7KwKHmDJHsidR9oSHScL2UCIvbTY4MWYUOlvIJNyQx3Z0g9Sjp8xRoeMgUz0dcYo4EkmJiw59R1JQsb7wqyntB9WGSKCHU0cptm-Jx/s1600/ss.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;23&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpjxREOUTr2bXQ28GIn9O1UvWS-UrfuxzRZI5CbT7KwKHmDJHsidR9oSHScL2UCIvbTY4MWYUOlvIJNyQx3Z0g9Sjp8xRoeMgUz0dcYo4EkmJiw59R1JQsb7wqyntB9WGSKCHU0cptm-Jx/s640/ss.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Notice the NULL value for the nonexistent key coming at the end. This query works without any error because of &lt;b&gt;lax &lt;/b&gt;mode&lt;br /&gt;
Now lets see what happens with the same query in the &lt;b&gt;strict &lt;/b&gt;mode&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SELECT JSON_VALUE(@x,&#39;strict $.Order.OrderDesc&#39;) AS OrderDesc,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_VALUE(@x,&#39;strict $.Order.OrderDate&#39;) AS OrderDate,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_VALUE(@x,&#39;strict $.Order.ShippedDate&#39;) AS ShippedDate,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_VALUE(@x,&#39;strict $.Order.WebOrder&#39;) AS WebOrder,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_VALUE(@x,&#39;strict $.Order.OrderItems.OrderQty&#39;) AS OrderQty,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_VALUE(@x,&#39;strict $.Order.OrderItems.Item[0].ItemDesc&#39;) AS ItemDesc1,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_VALUE(@x,&#39;strict $.Order.OrderItems.Item[0].Unitprice&#39;) AS Unitprice1,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_VALUE(@x,&#39;strict $.Order.OrderItems.Item[0].SUbItem[0].SubItemDesc&#39;) AS SubItemDesc11,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_VALUE(@x,&#39;strict $.Order.OrderItems.Item[0].SUbItem[1].SubItemDesc&#39;) AS SubItemDesc12,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_VALUE(@x,&#39;strict $.Order.OrderItems.Item[1].ItemDesc&#39;) AS ItemDesc2,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_VALUE(@x,&#39;strict $.Order.OrderItems.Item[1].Unitprice&#39;) AS Unitprice2,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_VALUE(@x,&#39;strict $.Order.OrderItems.Item[1].SUbItem[0].SubItemDesc&#39;) AS SubItemDesc21,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_VALUE(@x,&#39;strict $.Order.OrderItems.Item[1].SUbItem[1].SubItemDesc&#39;) AS SubItemDesc22&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Now the result&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4mfeCnydL9FUgf_zb-7CABGVcRcB5004qE0nUbecnxR38EBMjdp0JPeUjxT8KrMGk3dQ-ISQTeIQl16C4yDF538FfvHs6IFbEayH0TfPYWNlDhzj_mulIPq8rF7p48YVdAHd1ZvuqkYyf/s1600/ss.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;52&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4mfeCnydL9FUgf_zb-7CABGVcRcB5004qE0nUbecnxR38EBMjdp0JPeUjxT8KrMGk3dQ-ISQTeIQl16C4yDF538FfvHs6IFbEayH0TfPYWNlDhzj_mulIPq8rF7p48YVdAHd1ZvuqkYyf/s400/ss.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
As seen from the above example it throws an error when it finds an non existent key as per the specified path in the strict mode.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2 style=&quot;clear: both; text-align: left;&quot;&gt;
JSON_QUERY()&lt;/h2&gt;
&lt;div&gt;
JSON_QUERY function works similar to JSON_VALUE with the exception that it accepts a JSON path and returns a JSON document as the result&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
See the below example to understand how JSON_QUERY works&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;declare @x nvarchar(max) = &#39;{&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &quot;Order&quot;:&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderDesc&quot;: &quot;Order 1&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderDate&quot;: &quot;2013-02-12T00:00:00&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ShippedDate&quot;: &quot;2013-02-20T00:00:00&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;WebOrder&quot;: false,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderItems&quot;:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderQty&quot;: 10,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Item&quot;:&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;Wireless Mouse&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Unitprice&quot;: 30,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SUbItem&quot;:&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SubItemDesc&quot;: &quot;SP17&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;   &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;}&#39;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SELECT JSON_QUERY(@x,&#39;$.Order.OrderItems&#39;) AS OrderItems,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_QUERY(@x,&#39;$.Order.OrderItems.Item&#39;) AS Item,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_QUERY(@x,&#39;$.Order.OrderItems.Item.SUbItem&#39;) AS SubItem&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
The result will contain three JSON documents as shown below&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrnMaXCDCRMS6WcX7Soki4Ev7Eltf4Dk_pAcIrMTDeV-PSNgq2-It8eAiMRn-pI6ohLMO4nDaGsMpx0LNjfBECtHeOIBsGrJWT7VVtMcwLzBf0cqxjcAo5LwTQUeukgMn_vvH0bxtsPx2t/s1600/ss.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;23&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrnMaXCDCRMS6WcX7Soki4Ev7Eltf4Dk_pAcIrMTDeV-PSNgq2-It8eAiMRn-pI6ohLMO4nDaGsMpx0LNjfBECtHeOIBsGrJWT7VVtMcwLzBf0cqxjcAo5LwTQUeukgMn_vvH0bxtsPx2t/s400/ss.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
JSON_QUERY function similar to JSON_VALUE works in two supported modes &lt;b&gt;lax &lt;/b&gt;and &lt;b&gt;strict &lt;/b&gt;with lax being the default.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
The functionality remains the same with &lt;b&gt;strict &lt;/b&gt;mode throwing an error in case of passing an invalid path as compared to &lt;b&gt;lax &lt;/b&gt;mode returning a NULL value&lt;/div&gt;
&lt;div&gt;
Here is an illustration on the same&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;declare @x nvarchar(max) = &#39;{&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &quot;Order&quot;:&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderDesc&quot;: &quot;Order 1&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderDate&quot;: &quot;2013-02-12T00:00:00&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ShippedDate&quot;: &quot;2013-02-20T00:00:00&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;WebOrder&quot;: false,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderItems&quot;:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderQty&quot;: 10,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Item&quot;:&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;Wireless Mouse&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Unitprice&quot;: 30,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SUbItem&quot;:&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SubItemDesc&quot;: &quot;SP17&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;   &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;}&#39;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SELECT JSON_QUERY(@x,&#39;lax $.Order.OrderItems&#39;) AS OrderItems,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_QUERY(@x,&#39;lax $.Order.OrderItems.Item&#39;) AS Item,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_QUERY(@x,&#39;lax $.Order.OrderItems.Item.SUbItem&#39;) AS SubItem,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_QUERY(@x,&#39;lax $.Order.Customer&#39;) AS Customer&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
Result is as given below&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkE3iu0_af34rm0XBNJKrnCtaZ5C2tq_cRHlbS7zYbGd5Ia4zftvorRkdazHmpNXgGOY3yoJIGTbkzQZ4oxBoYg9zzA2szhQjMh6uT5g5w2mxMvEBeoMM6QZbEB0MkYhxBvyT158qIBvCM/s1600/ss.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;36&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkE3iu0_af34rm0XBNJKrnCtaZ5C2tq_cRHlbS7zYbGd5Ia4zftvorRkdazHmpNXgGOY3yoJIGTbkzQZ4oxBoYg9zzA2szhQjMh6uT5g5w2mxMvEBeoMM6QZbEB0MkYhxBvyT158qIBvCM/s640/ss.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Now strict mode will be as below&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SELECT JSON_QUERY(@x,&#39;strict $.Order.OrderItems&#39;) AS OrderItems,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_QUERY(@x,&#39;strict $.Order.OrderItems.Item&#39;) AS Item,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_QUERY(@x,&#39;strict $.Order.OrderItems.Item.SUbItem&#39;) AS SubItem,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JSON_QUERY(@x,&#39;strict $.Order.Customer&#39;) AS Customer&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
with the result&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5IveI187X2r2_egJAPSbm-16OGZjdSyU-L7R-UB8NQzbXdnVa4m3NH4icUMKgMnLm6ZOuGT1-bSs4X8QPRmfvhPMNqSx3S6rYz-MGZYrEIeCIzmq1PDlW1T0y3SkzwR74evcz_lgIbIYj/s1600/ss.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;52&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5IveI187X2r2_egJAPSbm-16OGZjdSyU-L7R-UB8NQzbXdnVa4m3NH4icUMKgMnLm6ZOuGT1-bSs4X8QPRmfvhPMNqSx3S6rYz-MGZYrEIeCIzmq1PDlW1T0y3SkzwR74evcz_lgIbIYj/s400/ss.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2 style=&quot;clear: both; text-align: left;&quot;&gt;
Parsing JSON Array Objects And Nested Levels&lt;/h2&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Now lets look at how JSON array objects and JSON documents with nested levels can be parsed.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Both the functions JSON_QUERY and JSON_VALUE can only parse a single JSON element at a time. Hence when we have to have to use a construct which helps us to iterate through each object in the array before we apply JSON_VALUE or JSON_QUERY over it.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
If you have read my earlier &lt;a href=&quot;http://visakhm.blogspot.ae/2016/07/whats-new-in-sql-2016-native-json.html&quot;&gt;article on JSON support&lt;/a&gt; you would be able to make out that we can use OPENJSON construct to iterate through the JSON document array.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Once OPENJSON is applied it returns as a elements of JSON as a resultset over which we can apply the JSON_VALUE or the JSON_QUERY function to return us a single scalar value or a JSON element depending on the case.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Now lets see an illustration to understand this&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Consider the example given below&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;declare @x nvarchar(max) = &#39;{&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &quot;Orders&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderDesc&quot;: &quot;Order 1&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderDate&quot;: &quot;2013-02-12T00:00:00&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ShippedDate&quot;: &quot;2013-02-20T00:00:00&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;WebOrder&quot;: false,&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderItems&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderQty&quot;: 10,&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Item&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;Wireless Mouse&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Unitprice&quot;: 30,&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SUbItem&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SubItemDesc&quot;: &quot;SP17&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ]&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ]&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; },&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderQty&quot;: 8,&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Item&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;Copier Ink&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Unitprice&quot;: 20,&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SUbItem&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SubItemDesc&quot;: &quot;SP5&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; },&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SubItemDesc&quot;: &quot;SP12&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ]&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ]&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; ],&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Customer&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;CustomerDesc&quot;: &quot;KBC Associates&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; ]&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; },&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderDesc&quot;: &quot;Order 2&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderDate&quot;: &quot;2015-06-24T00:00:00&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ShippedDate&quot;: &quot;2015-06-30T00:00:00&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;WebOrder&quot;: false,&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderItems&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderQty&quot;: 12,&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Item&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;Printer Catridge&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Unitprice&quot;: 112,&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SUbItem&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SubItemDesc&quot;: &quot;SP1&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; },&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SubItemDesc&quot;: &quot;SP3&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ]&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ]&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; ],&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Customer&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;CustomerDesc&quot;: &quot;ABC inc&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; ]&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; },&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderDesc&quot;: &quot;Order 5&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderDate&quot;: &quot;2016-05-17T00:00:00&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ShippedDate&quot;: &quot;2016-05-22T00:00:00&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;WebOrder&quot;: true,&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderItems&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderQty&quot;: 28,&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Item&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;Monitor CRT 18\&quot;&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Unitprice&quot;: 200&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ]&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; ],&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Customer&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;CustomerDesc&quot;: &quot;AAM &amp;amp; Co&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; ]&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; ]&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;}&#39;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
If you analyze the above example you can see that JSON document consist of array of JSON objects each with nested JSON array objects within them. Since it involved JSON array objects we would require OPENJSON function to parse them. Once we get individual JSON elements we can then apply JSON_VALUE or JSON_QUERY over them&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
So the query will look like this&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SELECT JSON_VALUE(value,&#39;$.OrderDesc&#39;) AS OrderDesc,&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;TRY_CONVERT(datetime,JSON_VALUE(value,&#39;$.OrderDate&#39;)) AS OrderDate,&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;TRY_CONVERT(datetime,JSON_VALUE(value,&#39;$.ShippedDate&#39;)) AS ShippedDate,&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;JSON_VALUE(value,&#39;$.WebOrder&#39;) AS WebOrder,&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;JSON_VALUE(oi,&#39;$.OrderQty&#39;) AS OrderQty,&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;JSON_VALUE(i,&#39;$.ItemDesc&#39;) AS ItemDesc,&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;JSON_VALUE(i,&#39;$.Unitprice&#39;) AS UnitPrice,&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;JSON_VALUE(si,&#39;$.SubItemDesc&#39;) AS SubItemDesc,&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;JSON_VALUE(c,&#39;$.CustomerDesc&#39;) AS CustomerDesc&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;FROM OPENJSON(@x,&#39;$.Orders&#39;) t&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;CROSS APPLY (SELECT JSON_QUERY(t.value,&#39;$.Customer[0]&#39;)) m(c)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;CROSS APPLY (SELECT value FROM OPENJSON(t.value,&#39;$.OrderItems&#39;))n(oi)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;CROSS APPLY (SELECT value FROM OPENJSON(oi,&#39;$.Item&#39;))p(i)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;OUTER APPLY (SELECT value FROM OPENJSON(i,&#39;$.SUbItem&#39;))q(si)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
The resultset for the query is as given below&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpgdHSgoPrKAa_bK1tj-7pN_2e6opRjNhyv_GzzgudSUMAUbMAo95nNtbnlpSdFLFFsSmkRiy0w2JmwNlkBNW6iozu4Q01xFpNNL38X3Z10mT4MkkEGPu1L-7PuEF88nuKj3i_Uxl8zHR5/s1600/ss.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;106&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpgdHSgoPrKAa_bK1tj-7pN_2e6opRjNhyv_GzzgudSUMAUbMAo95nNtbnlpSdFLFFsSmkRiy0w2JmwNlkBNW6iozu4Q01xFpNNL38X3Z10mT4MkkEGPu1L-7PuEF88nuKj3i_Uxl8zHR5/s640/ss.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
As seen from the above case, for iterating through JSON array we make use of OPENJSON. Within the array each &amp;nbsp;individual JSON document can be fetched using &amp;nbsp;JSON_QUERY function. In the above case since there is only single customer element we retrieve it using JSON_QUERY function and then apply series of JSON_VALUE function calls to return each key value within it. For the other documents which holds an array object we use further correlated OPENJSON calls by using APPLY operator and for each of the returned JSON documents we apply JSON_VALUE functions to return individual key element values.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
One thing to note here is that path being passed is case sensitive so you need to make sure you pass path in the exact case as how it appears within the JSON document&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
If you want a filter to be applied on above query you can make use of JSON_VALUE to make sure you retrieve only the documents where scalar value returned matches a given condition&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Like for example&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SELECT JSON_VALUE(value,&#39;$.OrderDesc&#39;) AS OrderDesc,&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;TRY_CONVERT(datetime,JSON_VALUE(value,&#39;$.OrderDate&#39;)) AS OrderDate,&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;TRY_CONVERT(datetime,JSON_VALUE(value,&#39;$.ShippedDate&#39;)) AS ShippedDate,&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;JSON_VALUE(value,&#39;$.WebOrder&#39;) AS WebOrder,&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;JSON_VALUE(oi,&#39;$.OrderQty&#39;) AS OrderQty,&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;JSON_VALUE(i,&#39;$.ItemDesc&#39;) AS ItemDesc,&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;JSON_VALUE(i,&#39;$.Unitprice&#39;) AS UnitPrice,&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;JSON_VALUE(si,&#39;$.SubItemDesc&#39;) AS SubItemDesc,&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;JSON_VALUE(c,&#39;$.CustomerDesc&#39;) AS CustomerDesc&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;FROM OPENJSON(@x,&#39;$.Orders&#39;) t&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;CROSS APPLY (SELECT JSON_QUERY(t.value,&#39;$.Customer[0]&#39;)) m(c)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;CROSS APPLY (SELECT value FROM OPENJSON(t.value,&#39;$.OrderItems&#39;))n(oi)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;CROSS APPLY (SELECT value FROM OPENJSON(oi,&#39;$.Item&#39;))p(i)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;OUTER APPLY (SELECT value FROM OPENJSON(i,&#39;$.SUbItem&#39;))q(si)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;WHERE JSON_VALUE(oi,&#39;$.OrderQty&#39;) &amp;gt; 20&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
This will only retrieve the data for the case where specified key value condition is satisfies within the JSON element and we will get the below output&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFd2dhUNsPC5TIbUfDhQ2YLLfEC_jt57NfbE5hbxmidN4dq23QR4MUg2BQFnq0fyTYkWNo1cSadWAWLPtaTFbAoKwEQ_rctx3Kvt42pdtEJlWick8v6puvc2Oj5QiE_mO-yAlfg85rSUrE/s1600/ss.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;34&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFd2dhUNsPC5TIbUfDhQ2YLLfEC_jt57NfbE5hbxmidN4dq23QR4MUg2BQFnq0fyTYkWNo1cSadWAWLPtaTFbAoKwEQ_rctx3Kvt42pdtEJlWick8v6puvc2Oj5QiE_mO-yAlfg85rSUrE/s640/ss.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2 style=&quot;clear: both; text-align: left;&quot;&gt;
JSON_MODIFY()&lt;/h2&gt;
&lt;div&gt;
JSON_MODIFY function as the name implies allows us to modify the data within an existing JSON document. This function can be used in cases where we need to replace an existing value or set a new value to a key within JSON document. We can also use it to rename a given JSON document key.&lt;/div&gt;
&lt;div&gt;
The syntax of JSON_MODIFY us as below&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
JSON_MODIFY(JSONexpression, JSON Path, value)&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Lets now see JSON_MODIFY function in action&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Consider this simple example&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;declare @x nvarchar(max) = &#39;{&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&quot;Order&quot;: {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderDesc&quot;: &quot;Order 1&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderDate&quot;: &quot;2013-02-12T00:00:00&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ShippedDate&quot;: &quot;2013-02-20T00:00:00&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;WebOrder&quot;: false,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderItems&quot;:&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderQty&quot;: 10,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Item&quot;: {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;Wireless Mouse&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Unitprice&quot;: &quot;30&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SUbItem&quot;: {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SubItemDesc&quot;: &quot;SP17&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;}&#39;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Now lets try to update value of Unitprice key in Item to 50 using JSON_MODIFY&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
The code will look like this&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SELECT JSON_VALUE(@x,&#39;$.Order.OrderItems.Item.Unitprice&#39;) AS Unitprice&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp;SET @x = JSON_MODIFY(@x,&#39;$.Order.OrderItems.Item.Unitprice&#39;,50)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp;SELECT @x,JSON_VALUE(@x,&#39;$.Order.OrderItems.Item.Unitprice&#39;) AS Unitprice&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
The corresponding result will be as below&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUmEqLqasrunsRGAT1jzCqFWQheeSMQfV2Npkp58UL249_RHJb0RxAiij9wEK4GaSJ3WCepEVVfJkyf30HRt9Hh5Y2FFaP0WxPkwQwI0UssdAdq2T-4cgK6qZDvYMFAJoc3k6-MZviIq4e/s1600/ss.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;141&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUmEqLqasrunsRGAT1jzCqFWQheeSMQfV2Npkp58UL249_RHJb0RxAiij9wEK4GaSJ3WCepEVVfJkyf30HRt9Hh5Y2FFaP0WxPkwQwI0UssdAdq2T-4cgK6qZDvYMFAJoc3k6-MZviIq4e/s400/ss.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
As seen from the result the key value got updated to 50&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Now lets see someother applications of JSON_MODIFY.&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
As specified earlier JSON_MODIFY can also be used to create a new key within JSON element, append a value to existing object array, rename a key within a JSON element or delete a key within JSON_MODIFY.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Lets see some illustrations below&lt;/div&gt;
&lt;h4 style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;1. Create a new key to JSON element&lt;/h4&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SET @x = JSON_MODIFY(@x,&#39;$.Order.OrderItems.Item.ItemQty&#39;,50)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SELECT @x&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
The result is as below&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;sBrace structure-1&quot; id=&quot;s-1&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;{&amp;nbsp;&lt;a href=&quot;https://www.blogger.com/null&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; box-sizing: border-box;&quot;&gt;&lt;span class=&quot;fa fa-minus-square-o&quot; style=&quot;-webkit-font-smoothing: antialiased; box-sizing: border-box; display: inline-block; font-family: FontAwesome; line-height: 1; position: relative; top: 2px;&quot;&gt;&lt;/span&gt;&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sObjectK&quot; id=&quot;s-2&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: 700; line-height: 22.8571px;&quot;&gt;&quot;Order&quot;&lt;/span&gt;&lt;span class=&quot;sColon&quot; id=&quot;s-3&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;sBrace structure-2&quot; id=&quot;s-4&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;{&amp;nbsp;&lt;a href=&quot;https://www.blogger.com/null&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; box-sizing: border-box;&quot;&gt;&lt;span class=&quot;fa fa-minus-square-o&quot; style=&quot;-webkit-font-smoothing: antialiased; box-sizing: border-box; display: inline-block; font-family: FontAwesome; line-height: 1; position: relative; top: 2px;&quot;&gt;&lt;/span&gt;&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sObjectK&quot; id=&quot;s-5&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: 700; line-height: 22.8571px;&quot;&gt;&quot;OrderDesc&quot;&lt;/span&gt;&lt;span class=&quot;sColon&quot; id=&quot;s-6&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;sObjectV&quot; id=&quot;s-7&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&quot;Order&amp;nbsp;1&quot;&lt;/span&gt;&lt;span class=&quot;sComma&quot; id=&quot;s-8&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;,&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sObjectK&quot; id=&quot;s-9&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: 700; line-height: 22.8571px;&quot;&gt;&quot;OrderDate&quot;&lt;/span&gt;&lt;span class=&quot;sColon&quot; id=&quot;s-10&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;sObjectV&quot; id=&quot;s-11&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&quot;2013-02-12T00:00:00&quot;&lt;/span&gt;&lt;span class=&quot;sComma&quot; id=&quot;s-12&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;,&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sObjectK&quot; id=&quot;s-13&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: 700; line-height: 22.8571px;&quot;&gt;&quot;ShippedDate&quot;&lt;/span&gt;&lt;span class=&quot;sColon&quot; id=&quot;s-14&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;sObjectV&quot; id=&quot;s-15&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&quot;2013-02-20T00:00:00&quot;&lt;/span&gt;&lt;span class=&quot;sComma&quot; id=&quot;s-16&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;,&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sObjectK&quot; id=&quot;s-17&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: 700; line-height: 22.8571px;&quot;&gt;&quot;WebOrder&quot;&lt;/span&gt;&lt;span class=&quot;sColon&quot; id=&quot;s-18&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;sObjectV&quot; id=&quot;s-19&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;sComma&quot; id=&quot;s-20&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;,&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sObjectK&quot; id=&quot;s-21&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: 700; line-height: 22.8571px;&quot;&gt;&quot;OrderItems&quot;&lt;/span&gt;&lt;span class=&quot;sColon&quot; id=&quot;s-22&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;sBrace structure-3&quot; id=&quot;s-23&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;{&amp;nbsp;&lt;a href=&quot;https://www.blogger.com/null&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; box-sizing: border-box;&quot;&gt;&lt;span class=&quot;fa fa-minus-square-o&quot; style=&quot;-webkit-font-smoothing: antialiased; box-sizing: border-box; display: inline-block; font-family: FontAwesome; line-height: 1; position: relative; top: 2px;&quot;&gt;&lt;/span&gt;&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sObjectK&quot; id=&quot;s-24&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: 700; line-height: 22.8571px;&quot;&gt;&quot;OrderQty&quot;&lt;/span&gt;&lt;span class=&quot;sColon&quot; id=&quot;s-25&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;sObjectV&quot; id=&quot;s-26&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;sComma&quot; id=&quot;s-27&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;,&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sObjectK&quot; id=&quot;s-28&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: 700; line-height: 22.8571px;&quot;&gt;&quot;Item&quot;&lt;/span&gt;&lt;span class=&quot;sColon&quot; id=&quot;s-29&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;sBrace structure-4&quot; id=&quot;s-30&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;{&amp;nbsp;&lt;a href=&quot;https://www.blogger.com/null&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; box-sizing: border-box;&quot;&gt;&lt;span class=&quot;fa fa-minus-square-o&quot; style=&quot;-webkit-font-smoothing: antialiased; box-sizing: border-box; display: inline-block; font-family: FontAwesome; line-height: 1; position: relative; top: 2px;&quot;&gt;&lt;/span&gt;&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sObjectK&quot; id=&quot;s-31&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: 700; line-height: 22.8571px;&quot;&gt;&quot;ItemDesc&quot;&lt;/span&gt;&lt;span class=&quot;sColon&quot; id=&quot;s-32&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;sObjectV&quot; id=&quot;s-33&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&quot;Wireless&amp;nbsp;Mouse&quot;&lt;/span&gt;&lt;span class=&quot;sComma&quot; id=&quot;s-34&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;,&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sObjectK&quot; id=&quot;s-35&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: 700; line-height: 22.8571px;&quot;&gt;&quot;Unitprice&quot;&lt;/span&gt;&lt;span class=&quot;sColon&quot; id=&quot;s-36&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;sObjectV&quot; id=&quot;s-37&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&quot;30&quot;&lt;/span&gt;&lt;span class=&quot;sComma&quot; id=&quot;s-38&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;,&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sObjectK&quot; id=&quot;s-39&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: 700; line-height: 22.8571px;&quot;&gt;&quot;SUbItem&quot;&lt;/span&gt;&lt;span class=&quot;sColon&quot; id=&quot;s-40&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;sBrace structure-5&quot; id=&quot;s-41&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;{&amp;nbsp;&lt;a href=&quot;https://www.blogger.com/null&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; box-sizing: border-box;&quot;&gt;&lt;span class=&quot;fa fa-minus-square-o&quot; style=&quot;-webkit-font-smoothing: antialiased; box-sizing: border-box; display: inline-block; font-family: FontAwesome; line-height: 1; position: relative; top: 2px;&quot;&gt;&lt;/span&gt;&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sObjectK&quot; id=&quot;s-42&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: 700; line-height: 22.8571px;&quot;&gt;&quot;SubItemDesc&quot;&lt;/span&gt;&lt;span class=&quot;sColon&quot; id=&quot;s-43&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;sObjectV&quot; id=&quot;s-44&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&quot;SP17&quot;&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sBrace structure-5&quot; id=&quot;s-45&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sComma&quot; id=&quot;s-46&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;,&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sObjectK&quot; id=&quot;s-47&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: 700; line-height: 22.8571px;&quot;&gt;&quot;ItemQty&quot;&lt;/span&gt;&lt;span class=&quot;sColon&quot; id=&quot;s-48&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;:5&lt;/span&gt;&lt;span class=&quot;sObjectV&quot; id=&quot;s-49&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;0&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sBrace structure-4&quot; id=&quot;s-50&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;}&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sBrace structure-3&quot; id=&quot;s-51&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;}&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sBrace structure-2&quot; id=&quot;s-52&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;}&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span class=&quot;sBrace structure-1&quot; id=&quot;s-53&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h4 style=&quot;clear: both; text-align: left;&quot;&gt;
2. Append a value to JSON element&lt;/h4&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;declare @x nvarchar(max) = &#39;{&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&quot;Order&quot;: {&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderDesc&quot;: &quot;Order 1&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderDate&quot;: &quot;2013-02-12T00:00:00&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ShippedDate&quot;: &quot;2013-02-20T00:00:00&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;WebOrder&quot;: false,&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderItems&quot;:&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderQty&quot;: 10,&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Item&quot;: {&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: [&quot;Wireless Mouse&quot;],&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Unitprice&quot;: &quot;30&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SUbItem&quot;: {&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SubItemDesc&quot;: &quot;SP17&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; }&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;}&#39;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SET @x = JSON_MODIFY(@x,&#39;append $.Order.OrderItems.Item.ItemDesc&#39;,&#39;Optical USB Enabled&#39;)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SELECT @x&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
The resulting JSON document is as below&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;sBrace structure-1&quot; id=&quot;s-1&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;{&amp;nbsp;&lt;a href=&quot;https://www.blogger.com/null&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; box-sizing: border-box;&quot;&gt;&lt;span class=&quot;fa fa-minus-square-o&quot; style=&quot;-webkit-font-smoothing: antialiased; box-sizing: border-box; display: inline-block; font-family: FontAwesome; line-height: 1; position: relative; top: 2px;&quot;&gt;&lt;/span&gt;&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sObjectK&quot; id=&quot;s-2&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: 700; line-height: 22.8571px;&quot;&gt;&quot;Order&quot;&lt;/span&gt;&lt;span class=&quot;sColon&quot; id=&quot;s-3&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;sBrace structure-2&quot; id=&quot;s-4&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;{&amp;nbsp;&lt;a href=&quot;https://www.blogger.com/null&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; box-sizing: border-box;&quot;&gt;&lt;span class=&quot;fa fa-minus-square-o&quot; style=&quot;-webkit-font-smoothing: antialiased; box-sizing: border-box; display: inline-block; font-family: FontAwesome; line-height: 1; position: relative; top: 2px;&quot;&gt;&lt;/span&gt;&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sObjectK&quot; id=&quot;s-5&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: 700; line-height: 22.8571px;&quot;&gt;&quot;OrderDesc&quot;&lt;/span&gt;&lt;span class=&quot;sColon&quot; id=&quot;s-6&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;sObjectV&quot; id=&quot;s-7&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&quot;Order&amp;nbsp;1&quot;&lt;/span&gt;&lt;span class=&quot;sComma&quot; id=&quot;s-8&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;,&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sObjectK&quot; id=&quot;s-9&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: 700; line-height: 22.8571px;&quot;&gt;&quot;OrderDate&quot;&lt;/span&gt;&lt;span class=&quot;sColon&quot; id=&quot;s-10&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;sObjectV&quot; id=&quot;s-11&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&quot;2013-02-12T00:00:00&quot;&lt;/span&gt;&lt;span class=&quot;sComma&quot; id=&quot;s-12&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;,&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sObjectK&quot; id=&quot;s-13&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: 700; line-height: 22.8571px;&quot;&gt;&quot;ShippedDate&quot;&lt;/span&gt;&lt;span class=&quot;sColon&quot; id=&quot;s-14&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;sObjectV&quot; id=&quot;s-15&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&quot;2013-02-20T00:00:00&quot;&lt;/span&gt;&lt;span class=&quot;sComma&quot; id=&quot;s-16&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;,&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sObjectK&quot; id=&quot;s-17&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: 700; line-height: 22.8571px;&quot;&gt;&quot;WebOrder&quot;&lt;/span&gt;&lt;span class=&quot;sColon&quot; id=&quot;s-18&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;sObjectV&quot; id=&quot;s-19&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;sComma&quot; id=&quot;s-20&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;,&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sObjectK&quot; id=&quot;s-21&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: 700; line-height: 22.8571px;&quot;&gt;&quot;OrderItems&quot;&lt;/span&gt;&lt;span class=&quot;sColon&quot; id=&quot;s-22&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;sBrace structure-3&quot; id=&quot;s-23&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;{&amp;nbsp;&lt;a href=&quot;https://www.blogger.com/null&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; box-sizing: border-box;&quot;&gt;&lt;span class=&quot;fa fa-minus-square-o&quot; style=&quot;-webkit-font-smoothing: antialiased; box-sizing: border-box; display: inline-block; font-family: FontAwesome; line-height: 1; position: relative; top: 2px;&quot;&gt;&lt;/span&gt;&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sObjectK&quot; id=&quot;s-24&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: 700; line-height: 22.8571px;&quot;&gt;&quot;OrderQty&quot;&lt;/span&gt;&lt;span class=&quot;sColon&quot; id=&quot;s-25&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;sObjectV&quot; id=&quot;s-26&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;sComma&quot; id=&quot;s-27&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;,&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sObjectK&quot; id=&quot;s-28&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: 700; line-height: 22.8571px;&quot;&gt;&quot;Item&quot;&lt;/span&gt;&lt;span class=&quot;sColon&quot; id=&quot;s-29&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;sBrace structure-4&quot; id=&quot;s-30&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;{&amp;nbsp;&lt;a href=&quot;https://www.blogger.com/null&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; box-sizing: border-box;&quot;&gt;&lt;span class=&quot;fa fa-minus-square-o&quot; style=&quot;-webkit-font-smoothing: antialiased; box-sizing: border-box; display: inline-block; font-family: FontAwesome; line-height: 1; position: relative; top: 2px;&quot;&gt;&lt;/span&gt;&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sObjectK&quot; id=&quot;s-31&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: 700; line-height: 22.8571px;&quot;&gt;&quot;ItemDesc&quot;&lt;/span&gt;&lt;span class=&quot;sColon&quot; id=&quot;s-32&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;sBracket structure-5&quot; id=&quot;s-33&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;[&amp;nbsp;&lt;a href=&quot;https://www.blogger.com/null&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; box-sizing: border-box;&quot;&gt;&lt;span class=&quot;fa fa-minus-square-o&quot; style=&quot;-webkit-font-smoothing: antialiased; box-sizing: border-box; display: inline-block; font-family: FontAwesome; line-height: 1; position: relative; top: 2px;&quot;&gt;&lt;/span&gt;&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sArrayV&quot; id=&quot;s-34&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&quot;Wireless&amp;nbsp;Mouse&quot;&lt;/span&gt;&lt;span class=&quot;sComma&quot; id=&quot;s-35&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;,&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sArrayV&quot; id=&quot;s-36&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&quot;Optical&amp;nbsp;USB&amp;nbsp;Enabled&quot;&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sBracket structure-5&quot; id=&quot;s-37&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;sComma&quot; id=&quot;s-38&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;,&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sObjectK&quot; id=&quot;s-39&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: 700; line-height: 22.8571px;&quot;&gt;&quot;Unitprice&quot;&lt;/span&gt;&lt;span class=&quot;sColon&quot; id=&quot;s-40&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;sObjectV&quot; id=&quot;s-41&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&quot;30&quot;&lt;/span&gt;&lt;span class=&quot;sComma&quot; id=&quot;s-42&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;,&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sObjectK&quot; id=&quot;s-43&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: 700; line-height: 22.8571px;&quot;&gt;&quot;SUbItem&quot;&lt;/span&gt;&lt;span class=&quot;sColon&quot; id=&quot;s-44&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;sBrace structure-5&quot; id=&quot;s-45&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;{&amp;nbsp;&lt;a href=&quot;https://www.blogger.com/null&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; box-sizing: border-box;&quot;&gt;&lt;span class=&quot;fa fa-minus-square-o&quot; style=&quot;-webkit-font-smoothing: antialiased; box-sizing: border-box; display: inline-block; font-family: FontAwesome; line-height: 1; position: relative; top: 2px;&quot;&gt;&lt;/span&gt;&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sObjectK&quot; id=&quot;s-46&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: 700; line-height: 22.8571px;&quot;&gt;&quot;SubItemDesc&quot;&lt;/span&gt;&lt;span class=&quot;sColon&quot; id=&quot;s-47&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;sObjectV&quot; id=&quot;s-48&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&quot;SP17&quot;&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sBrace structure-5&quot; id=&quot;s-49&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;}&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sBrace structure-4&quot; id=&quot;s-50&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;}&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sBrace structure-3&quot; id=&quot;s-51&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;}&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sBrace structure-2&quot; id=&quot;s-52&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;}&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span class=&quot;sBrace structure-1&quot; id=&quot;s-53&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
As seen above it appends the value passed to the ItemDesc array object.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h4 style=&quot;clear: both; text-align: left;&quot;&gt;
3. Rename a key within JSON document&lt;/h4&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Now lets see an example of the case where we need to rename a key within a JSON array&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SET @x = JSON_MODIFY(JSON_MODIFY(@x,&#39;$.Order.OrderItems.Item.SubItem&#39;,JSON_QUERY(@x,&#39;$.Order.OrderItems.Item.SUbItem&#39;)),&#39;$.Order.OrderItems.Item.SUbItem&#39;,NULL)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SELECT @x&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
The result as below&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;sBrace structure-1&quot; id=&quot;s-1&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;{&amp;nbsp;&lt;a href=&quot;https://www.blogger.com/null&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; box-sizing: border-box;&quot;&gt;&lt;span class=&quot;fa fa-minus-square-o&quot; style=&quot;-webkit-font-smoothing: antialiased; box-sizing: border-box; display: inline-block; font-family: FontAwesome; line-height: 1; position: relative; top: 2px;&quot;&gt;&lt;/span&gt;&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sObjectK&quot; id=&quot;s-2&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: 700; line-height: 22.8571px;&quot;&gt;&quot;Order&quot;&lt;/span&gt;&lt;span class=&quot;sColon&quot; id=&quot;s-3&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;sBrace structure-2&quot; id=&quot;s-4&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;{&amp;nbsp;&lt;a href=&quot;https://www.blogger.com/null&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; box-sizing: border-box;&quot;&gt;&lt;span class=&quot;fa fa-minus-square-o&quot; style=&quot;-webkit-font-smoothing: antialiased; box-sizing: border-box; display: inline-block; font-family: FontAwesome; line-height: 1; position: relative; top: 2px;&quot;&gt;&lt;/span&gt;&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sObjectK&quot; id=&quot;s-5&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: 700; line-height: 22.8571px;&quot;&gt;&quot;OrderDesc&quot;&lt;/span&gt;&lt;span class=&quot;sColon&quot; id=&quot;s-6&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;sObjectV&quot; id=&quot;s-7&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&quot;Order&amp;nbsp;1&quot;&lt;/span&gt;&lt;span class=&quot;sComma&quot; id=&quot;s-8&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;,&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sObjectK&quot; id=&quot;s-9&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: 700; line-height: 22.8571px;&quot;&gt;&quot;OrderDate&quot;&lt;/span&gt;&lt;span class=&quot;sColon&quot; id=&quot;s-10&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;sObjectV&quot; id=&quot;s-11&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&quot;2013-02-12T00:00:00&quot;&lt;/span&gt;&lt;span class=&quot;sComma&quot; id=&quot;s-12&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;,&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sObjectK&quot; id=&quot;s-13&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: 700; line-height: 22.8571px;&quot;&gt;&quot;ShippedDate&quot;&lt;/span&gt;&lt;span class=&quot;sColon&quot; id=&quot;s-14&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;sObjectV&quot; id=&quot;s-15&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&quot;2013-02-20T00:00:00&quot;&lt;/span&gt;&lt;span class=&quot;sComma&quot; id=&quot;s-16&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;,&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sObjectK&quot; id=&quot;s-17&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: 700; line-height: 22.8571px;&quot;&gt;&quot;WebOrder&quot;&lt;/span&gt;&lt;span class=&quot;sColon&quot; id=&quot;s-18&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;sObjectV&quot; id=&quot;s-19&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;sComma&quot; id=&quot;s-20&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;,&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sObjectK&quot; id=&quot;s-21&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: 700; line-height: 22.8571px;&quot;&gt;&quot;OrderItems&quot;&lt;/span&gt;&lt;span class=&quot;sColon&quot; id=&quot;s-22&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;sBrace structure-3&quot; id=&quot;s-23&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;{&amp;nbsp;&lt;a href=&quot;https://www.blogger.com/null&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; box-sizing: border-box;&quot;&gt;&lt;span class=&quot;fa fa-minus-square-o&quot; style=&quot;-webkit-font-smoothing: antialiased; box-sizing: border-box; display: inline-block; font-family: FontAwesome; line-height: 1; position: relative; top: 2px;&quot;&gt;&lt;/span&gt;&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sObjectK&quot; id=&quot;s-24&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: 700; line-height: 22.8571px;&quot;&gt;&quot;OrderQty&quot;&lt;/span&gt;&lt;span class=&quot;sColon&quot; id=&quot;s-25&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;sObjectV&quot; id=&quot;s-26&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;sComma&quot; id=&quot;s-27&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;,&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sObjectK&quot; id=&quot;s-28&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: 700; line-height: 22.8571px;&quot;&gt;&quot;Item&quot;&lt;/span&gt;&lt;span class=&quot;sColon&quot; id=&quot;s-29&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;sBrace structure-4&quot; id=&quot;s-30&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;{&amp;nbsp;&lt;a href=&quot;https://www.blogger.com/null&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; box-sizing: border-box;&quot;&gt;&lt;span class=&quot;fa fa-minus-square-o&quot; style=&quot;-webkit-font-smoothing: antialiased; box-sizing: border-box; display: inline-block; font-family: FontAwesome; line-height: 1; position: relative; top: 2px;&quot;&gt;&lt;/span&gt;&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sObjectK&quot; id=&quot;s-31&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: 700; line-height: 22.8571px;&quot;&gt;&quot;ItemDesc&quot;&lt;/span&gt;&lt;span class=&quot;sColon&quot; id=&quot;s-32&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;sBracket structure-5&quot; id=&quot;s-33&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;[&amp;nbsp;&lt;a href=&quot;https://www.blogger.com/null&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; box-sizing: border-box;&quot;&gt;&lt;span class=&quot;fa fa-minus-square-o&quot; style=&quot;-webkit-font-smoothing: antialiased; box-sizing: border-box; display: inline-block; font-family: FontAwesome; line-height: 1; position: relative; top: 2px;&quot;&gt;&lt;/span&gt;&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sArrayV&quot; id=&quot;s-34&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&quot;Wireless&amp;nbsp;Mouse&quot;&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sBracket structure-5&quot; id=&quot;s-35&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;sComma&quot; id=&quot;s-36&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;,&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sObjectK&quot; id=&quot;s-37&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: 700; line-height: 22.8571px;&quot;&gt;&quot;Unitprice&quot;&lt;/span&gt;&lt;span class=&quot;sColon&quot; id=&quot;s-38&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;sObjectV&quot; id=&quot;s-39&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&quot;30&quot;&lt;/span&gt;&lt;span class=&quot;sComma&quot; id=&quot;s-40&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;,&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sObjectK&quot; id=&quot;s-41&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: 700; line-height: 22.8571px;&quot;&gt;&quot;SubItem&quot;&lt;/span&gt;&lt;span class=&quot;sColon&quot; id=&quot;s-42&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;sBrace structure-5&quot; id=&quot;s-43&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;{&amp;nbsp;&lt;a href=&quot;https://www.blogger.com/null&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; box-sizing: border-box;&quot;&gt;&lt;span class=&quot;fa fa-minus-square-o&quot; style=&quot;-webkit-font-smoothing: antialiased; box-sizing: border-box; display: inline-block; font-family: FontAwesome; line-height: 1; position: relative; top: 2px;&quot;&gt;&lt;/span&gt;&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sObjectK&quot; id=&quot;s-44&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: 700; line-height: 22.8571px;&quot;&gt;&quot;SubItemDesc&quot;&lt;/span&gt;&lt;span class=&quot;sColon&quot; id=&quot;s-45&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;sObjectV&quot; id=&quot;s-46&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&quot;SP17&quot;&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sBrace structure-5&quot; id=&quot;s-47&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;}&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sBrace structure-4&quot; id=&quot;s-48&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;}&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sBrace structure-3&quot; id=&quot;s-49&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;}&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sBrace structure-2&quot; id=&quot;s-50&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
Analyse the result and you can see that the JSON document key element has been renamed from SUbitem to SubItem.&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;4. Delete a key within JSON document&lt;/h4&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;declare @x nvarchar(max) = &#39;{ &amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp;&quot;Order&quot;:{ &amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderDesc&quot;:&quot;Order 1&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderDate&quot;:&quot;2013-02-12T00:00:00&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ShippedDate&quot;:&quot;2013-02-20T00:00:00&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;WebOrder&quot;:false,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderItems&quot;:{ &amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&quot;OrderQty&quot;:10,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&quot;Item&quot;:{ &amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;:[ &amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&quot;Wireless Mouse&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ],&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Unitprice&quot;:&quot;30&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemQty&quot;:50,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SubItem&quot;:{ &amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&quot;SubItemDesc&quot;:&quot;SP17&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;}&#39;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
The code is as given below&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SET @x = JSON_MODIFY(@x,&#39;$.Order.OrderItems.Item.ItemQty&#39;,NULL)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SELECT @x&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
The result will look like this&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;sBrace structure-1&quot; id=&quot;s-1&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;{&amp;nbsp;&lt;a href=&quot;https://www.blogger.com/null&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; box-sizing: border-box;&quot;&gt;&lt;span class=&quot;fa fa-minus-square-o&quot; style=&quot;-webkit-font-smoothing: antialiased; box-sizing: border-box; display: inline-block; font-family: FontAwesome; line-height: 1; position: relative; top: 2px;&quot;&gt;&lt;/span&gt;&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sObjectK&quot; id=&quot;s-2&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: 700; line-height: 22.8571px;&quot;&gt;&quot;Order&quot;&lt;/span&gt;&lt;span class=&quot;sColon&quot; id=&quot;s-3&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;sBrace structure-2&quot; id=&quot;s-4&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;{&amp;nbsp;&lt;a href=&quot;https://www.blogger.com/null&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; box-sizing: border-box;&quot;&gt;&lt;span class=&quot;fa fa-minus-square-o&quot; style=&quot;-webkit-font-smoothing: antialiased; box-sizing: border-box; display: inline-block; font-family: FontAwesome; line-height: 1; position: relative; top: 2px;&quot;&gt;&lt;/span&gt;&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sObjectK&quot; id=&quot;s-5&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: 700; line-height: 22.8571px;&quot;&gt;&quot;OrderDesc&quot;&lt;/span&gt;&lt;span class=&quot;sColon&quot; id=&quot;s-6&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;sObjectV&quot; id=&quot;s-7&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&quot;Order&amp;nbsp;1&quot;&lt;/span&gt;&lt;span class=&quot;sComma&quot; id=&quot;s-8&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;,&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sObjectK&quot; id=&quot;s-9&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: 700; line-height: 22.8571px;&quot;&gt;&quot;OrderDate&quot;&lt;/span&gt;&lt;span class=&quot;sColon&quot; id=&quot;s-10&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;sObjectV&quot; id=&quot;s-11&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&quot;2013-02-12T00:00:00&quot;&lt;/span&gt;&lt;span class=&quot;sComma&quot; id=&quot;s-12&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;,&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sObjectK&quot; id=&quot;s-13&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: 700; line-height: 22.8571px;&quot;&gt;&quot;ShippedDate&quot;&lt;/span&gt;&lt;span class=&quot;sColon&quot; id=&quot;s-14&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;sObjectV&quot; id=&quot;s-15&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&quot;2013-02-20T00:00:00&quot;&lt;/span&gt;&lt;span class=&quot;sComma&quot; id=&quot;s-16&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;,&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sObjectK&quot; id=&quot;s-17&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: 700; line-height: 22.8571px;&quot;&gt;&quot;WebOrder&quot;&lt;/span&gt;&lt;span class=&quot;sColon&quot; id=&quot;s-18&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;sObjectV&quot; id=&quot;s-19&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;sComma&quot; id=&quot;s-20&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;,&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sObjectK&quot; id=&quot;s-21&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: 700; line-height: 22.8571px;&quot;&gt;&quot;OrderItems&quot;&lt;/span&gt;&lt;span class=&quot;sColon&quot; id=&quot;s-22&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;sBrace structure-3&quot; id=&quot;s-23&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;{&amp;nbsp;&lt;a href=&quot;https://www.blogger.com/null&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; box-sizing: border-box;&quot;&gt;&lt;span class=&quot;fa fa-minus-square-o&quot; style=&quot;-webkit-font-smoothing: antialiased; box-sizing: border-box; display: inline-block; font-family: FontAwesome; line-height: 1; position: relative; top: 2px;&quot;&gt;&lt;/span&gt;&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sObjectK&quot; id=&quot;s-24&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: 700; line-height: 22.8571px;&quot;&gt;&quot;OrderQty&quot;&lt;/span&gt;&lt;span class=&quot;sColon&quot; id=&quot;s-25&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;sObjectV&quot; id=&quot;s-26&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;sComma&quot; id=&quot;s-27&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;,&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sObjectK&quot; id=&quot;s-28&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: 700; line-height: 22.8571px;&quot;&gt;&quot;Item&quot;&lt;/span&gt;&lt;span class=&quot;sColon&quot; id=&quot;s-29&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;sBrace structure-4&quot; id=&quot;s-30&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;{&amp;nbsp;&lt;a href=&quot;https://www.blogger.com/null&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; box-sizing: border-box;&quot;&gt;&lt;span class=&quot;fa fa-minus-square-o&quot; style=&quot;-webkit-font-smoothing: antialiased; box-sizing: border-box; display: inline-block; font-family: FontAwesome; line-height: 1; position: relative; top: 2px;&quot;&gt;&lt;/span&gt;&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sObjectK&quot; id=&quot;s-31&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: 700; line-height: 22.8571px;&quot;&gt;&quot;ItemDesc&quot;&lt;/span&gt;&lt;span class=&quot;sColon&quot; id=&quot;s-32&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;sBracket structure-5&quot; id=&quot;s-33&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;[&amp;nbsp;&lt;a href=&quot;https://www.blogger.com/null&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; box-sizing: border-box;&quot;&gt;&lt;span class=&quot;fa fa-minus-square-o&quot; style=&quot;-webkit-font-smoothing: antialiased; box-sizing: border-box; display: inline-block; font-family: FontAwesome; line-height: 1; position: relative; top: 2px;&quot;&gt;&lt;/span&gt;&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sArrayV&quot; id=&quot;s-34&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&quot;Wireless&amp;nbsp;Mouse&quot;&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sBracket structure-5&quot; id=&quot;s-35&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;sComma&quot; id=&quot;s-36&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;,&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sObjectK&quot; id=&quot;s-37&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: 700; line-height: 22.8571px;&quot;&gt;&quot;Unitprice&quot;&lt;/span&gt;&lt;span class=&quot;sColon&quot; id=&quot;s-38&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;sObjectV&quot; id=&quot;s-39&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&quot;30&quot;&lt;/span&gt;&lt;span class=&quot;sComma&quot; id=&quot;s-40&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;,&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sObjectK&quot; id=&quot;s-41&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: 700; line-height: 22.8571px;&quot;&gt;&quot;SubItem&quot;&lt;/span&gt;&lt;span class=&quot;sColon&quot; id=&quot;s-42&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;sBrace structure-5&quot; id=&quot;s-43&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;{&amp;nbsp;&lt;a href=&quot;https://www.blogger.com/null&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; box-sizing: border-box;&quot;&gt;&lt;span class=&quot;fa fa-minus-square-o&quot; style=&quot;-webkit-font-smoothing: antialiased; box-sizing: border-box; display: inline-block; font-family: FontAwesome; line-height: 1; position: relative; top: 2px;&quot;&gt;&lt;/span&gt;&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sObjectK&quot; id=&quot;s-44&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: 700; line-height: 22.8571px;&quot;&gt;&quot;SubItemDesc&quot;&lt;/span&gt;&lt;span class=&quot;sColon&quot; id=&quot;s-45&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;sObjectV&quot; id=&quot;s-46&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&quot;SP17&quot;&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sBrace structure-5&quot; id=&quot;s-47&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;}&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sBrace structure-4&quot; id=&quot;s-48&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;}&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sBrace structure-3&quot; id=&quot;s-49&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;}&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;sBrace structure-2&quot; id=&quot;s-50&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;}&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot; /&gt;&lt;span class=&quot;sBrace structure-1&quot; id=&quot;s-51&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;sBrace structure-1&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Ubuntu Mono&amp;quot;, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22.8571px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
If you notice the result you will see that the ItemQty key is missing in the document which indicates that key has been deleted from the document.&lt;br /&gt;
&lt;br /&gt;
Please note that all the above queries are using the default &lt;b&gt;lax &lt;/b&gt;mode. While using &lt;b&gt;strict &lt;/b&gt;mode it will throw the standard error indicating JSON path not found if you pass a non existing key name.&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Conclusion&lt;/h2&gt;
&lt;div&gt;
The examples given above illustrate the options available in SQL 2016 using standard JSON functions to do the data manipulations within the JSON data.&lt;/div&gt;
&lt;div&gt;
One or more of these functions can be effectively used in cases where data within the JSON needs to be modified to get the desired result.&lt;/div&gt;
&lt;/div&gt;
</description><link>http://visakhm.blogspot.com/2016/07/whats-new-in-sql-2016-native-json_13.html</link><author>noreply@blogger.com (Visakh Murukesan)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjUehrbok3kDaR1w0MT2Z2RxE6BRo22VvUvMcpGQSDhqdwowNJF4R8rFWl7eln4AEGiDcylpuK__YFuG6XQjmASxBV8eSQgcA9DiV3b5ZrY9eroaWmh3Qp6cf1TtbvpQrwHlz3394Gr1UW/s72-c/ss.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7998687752365941655.post-722719717133835555</guid><pubDate>Fri, 08 Jul 2016 09:33:00 +0000</pubDate><atom:updated>2016-07-08T15:03:59.598+05:30</atom:updated><title>Whats New in SQL 2016 - Native JSON Function Support - Parsing JSON Document to Shred Relational Data</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Previously I had blogged about the native support for JSON in SQL 2016 and the ability to generate JSON documents from relational data using FOR JSON syntax &lt;a href=&quot;http://visakhm.blogspot.ae/2016/06/whats-new-in-sql-2016-native-json.html&quot;&gt;here&lt;/a&gt; .&lt;br /&gt;
This blog is next in the series on JSON support and explains about how you can use T-SQL code to parse and shred out data from existing JSON documents to load data to relational database tables.&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Illustration&lt;/h2&gt;
&lt;div&gt;
Consider the below JSON document&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;declare @x nvarchar(max)=&#39;{&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &quot;Item&quot;:{&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemID&quot;: 101,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;Monitor CRT 18\&quot;&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Unitprice&quot;: 200&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; }}&#39;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
Now lets see how we can shred out the data from this simple JSON element&lt;/div&gt;
&lt;div&gt;
We will make use OPENJSON function available in SQL 2016 for this purpose.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
The basic syntax for OPENJSON is as below&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;OPENJSON(jsonexpression,path)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
OPENJSON accepts a JSON document expression as the first argument and parses it based on path specified within the second argument&lt;/div&gt;
&lt;div&gt;
So in the above case we will write the query as below to parse the JSON document&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SELECT *&lt;br /&gt;FROM OPENJSON(@x,&#39;$.Item&#39;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
The output will look like below&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;key&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;value&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;type&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;---- &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; -------- &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ---------&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;ItemID&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 101&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;2&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;ItemDesc&amp;nbsp;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;Monitor CRT 18&quot;&amp;nbsp;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;1&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;Unitprice&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 200&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
This will be the standard format in which output is returned. If you analyze the result you will see that it consists of three columns first one giving the key names inside JSON document, second column giving the values corresponding to the keys and third one giving the data types of the values. &amp;nbsp;The full list of type values along with the corresponding data types can be seen in the below link&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;https://msdn.microsoft.com/en-us/library/dn921885.aspx&quot;&gt;https://msdn.microsoft.com/en-us/library/dn921885.aspx&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
If you want the get the Key names as columns along with their corresponding values &amp;nbsp;in the output you can use the optional WITH clause along with OPENJSON to transpose the result&lt;/div&gt;
&lt;div&gt;
The query in that case would look like this&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SELECT *&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;FROM OPENJSON(@x,&#39;$.Item&#39;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;WITH&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp;(&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;ItemID int,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;ItemDesc varchar(50),&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;Unitprice int&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
And result would be the below&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;ItemID&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ItemDesc&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;Unitprice&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;------------ &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;----------------- &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ------------------&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;101&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Monitor CRT 18&quot;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;200&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Parsing JSON Array&lt;/h2&gt;
&lt;div&gt;
Now lets see what happens in the case of document with an array of JSON values&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;declare @x nvarchar(max)=&#39;{&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &quot;Items&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemID&quot;: 101,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;Monitor CRT 18\&quot;&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Unitprice&quot;: 200&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; },&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemID&quot;: 110,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;Printer Catridge&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Unitprice&quot;: 112&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; },&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemID&quot;: 112,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;Copier Ink&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Unitprice&quot;: 20&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; },&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemID&quot;: 123,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;Wireless Mouse&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Unitprice&quot;: 30&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; ]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;}&#39;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SELECT *&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;FROM OPENJSON(@x,&#39;$.Items&#39;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;WITH&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;ItemID int,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;ItemDesc varchar(100),&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;Unitprice int&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
The above query will give you this result&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOAi958tHqLYlCpM5c7H7kj7PcluLNFNT2qc4eM-_4U1WCd5OrwagTA5D4Zi_QuFTjmLUTg_9-2w8HAKJc7t9Ch88n3uWk9CenI5xsHqQ6UYPe3S9yhIeeDgvr-cJR-ECFvbJCS4S3h_Yi/s1600/ss.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOAi958tHqLYlCpM5c7H7kj7PcluLNFNT2qc4eM-_4U1WCd5OrwagTA5D4Zi_QuFTjmLUTg_9-2w8HAKJc7t9Ch88n3uWk9CenI5xsHqQ6UYPe3S9yhIeeDgvr-cJR-ECFvbJCS4S3h_Yi/s1600/ss.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
The above examples shows how you can use OPENJSON to parse JSON documents to obtain relational data.&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Nested JSON Documents&lt;/h2&gt;
&lt;div&gt;
Now lets see what happens in the case where there are nested JSON documents. In such case a single OPENJSON wont be sufficient to extract the whole data.&lt;/div&gt;
&lt;div&gt;
Consider the below document as an example&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;declare&amp;nbsp;@json nvarchar(max)=&#39;{&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &quot;Orders&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderDesc&quot;: &quot;Order 1&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderDate&quot;: &quot;2013-02-12T00:00:00&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ShippedDate&quot;: &quot;2013-02-20T00:00:00&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;WebOrder&quot;: false,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderItems&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderQty&quot;: 10,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Item&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;Wireless Mouse&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Unitprice&quot;: 30,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SubItem&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SubItemDesc&quot;: &quot;SP17&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; },&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderQty&quot;: 8,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Item&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;Copier Ink&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Unitprice&quot;: 20,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SubItem&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SubItemDesc&quot;: &quot;SP5&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; },&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SubItemDesc&quot;: &quot;SP12&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; ],&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Customer&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;CustomerDesc&quot;: &quot;KBC Associates&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; ]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; },&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderDesc&quot;: &quot;Order 2&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderDate&quot;: &quot;2015-06-24T00:00:00&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ShippedDate&quot;: &quot;2015-06-30T00:00:00&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;WebOrder&quot;: false,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderItems&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderQty&quot;: 12,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Item&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;Printer Catridge&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Unitprice&quot;: 112,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SubItem&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SubItemDesc&quot;: &quot;SP1&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; },&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SubItemDesc&quot;: &quot;SP3&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; ],&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Customer&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;CustomerDesc&quot;: &quot;ABC inc&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; ]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; },&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderDesc&quot;: &quot;Order 5&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderDate&quot;: &quot;2016-05-17T00:00:00&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ShippedDate&quot;: &quot;2016-05-22T00:00:00&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;WebOrder&quot;: true,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderItems&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderQty&quot;: 28,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Item&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;Monitor CRT 18\&quot;&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Unitprice&quot;: 200&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; ],&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Customer&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;CustomerDesc&quot;: &quot;AAM &amp;amp; Co&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; ]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp; ]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;}&#39;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
The above is an example of &amp;nbsp;a JSON document with nested JSON elements going till 4th level. In such a case we need to use series of nested OPENJSON constructs to get data from JSON document as column data.&lt;/div&gt;
&lt;div&gt;
The query will look like this&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SELECT t.OrderDesc,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;t.OrderDate,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;t.ShippedDate,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;t.WebOrder,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;oi.OrderQty,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;c.CustomerDesc,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;i.ItemDesc,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;i.Unitprice,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;si.SubItemDesc&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;FROM OPENJSON(@json,&#39;$.Orders&#39;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;WITH (&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;OrderDesc varchar(20),&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;OrderDate datetime,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;ShippedDate datetime,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;WebOrder bit,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;OrderItems nvarchar(max) AS JSON,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;Customer nvarchar(max) AS JSON&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;)t&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;CROSS APPLY OPENJSON(OrderItems,&#39;$&#39;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;WITH&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;OrderQty int,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;Item nvarchar(max) AS JSON&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;)oi&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;CROSS APPLY OPENJSON(Customer,&#39;$&#39;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;WITH&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;CustomerDesc varchar(100)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;)c&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;CROSS APPLY OPENJSON(Item,&#39;$&#39;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;WITH&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;ItemDesc varchar(100),&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;Unitprice decimal(30,2),&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SubItem nvarchar(max) AS JSON&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;)i&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;OUTER APPLY OPENJSON(SubItem,&#39;$&#39;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;WITH&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SubItemDesc varchar(50)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;)si&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
And you will get the output as below&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_9_StIqoYv4Z5FDSGknBennUvwqFVXQVV4XewxjpjFhx5OcT5hbwr9udW8-r6IJKbujb5jZYw1KG-XnClE4IdR2Wm8BJTflWna4kHNlcYRl_yctrBzj3IfJgVJupwkvAoa0JVwEspIOkY/s1600/ss.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;107&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_9_StIqoYv4Z5FDSGknBennUvwqFVXQVV4XewxjpjFhx5OcT5hbwr9udW8-r6IJKbujb5jZYw1KG-XnClE4IdR2Wm8BJTflWna4kHNlcYRl_yctrBzj3IfJgVJupwkvAoa0JVwEspIOkY/s640/ss.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
If you analyze the query you can see that it uses a series of nested calls to OPENJSON to parse out the data at different levels within the JSON document.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&amp;nbsp;Each level it applies the WITH option to return the individual element values as well as returns the next level elements in JSON format itself using AS JSON option which is then parsed by next OPENJSON call by using CROSS or OUTER APPLY to pass the JSON value as a correlated parameter to the OPENJSON. This is continued till the last level to return the complete set of values from within each of JSON documents at the different levels. Depending whether you want a perfect match or not you can use CROSS or OUTER as the option for the APPLY operator.&amp;nbsp;&lt;/div&gt;
&lt;h2 style=&quot;clear: both; text-align: left;&quot;&gt;
JSON Path vs XPath&lt;/h2&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
If you compare the json path expressions used in the above examples against xpath expression you use for shredding XML data you can see that the basic format is very similar. Here we use $ to denote the root element as compared to / in case of XML. Also each child member is represented using . as &amp;nbsp;compared to / in XML. So anyone who has experience in writing XML XPath expressions in SQLServer will find it easy to follow JSON path expressions&lt;/div&gt;
&lt;h2 style=&quot;clear: both; text-align: left;&quot;&gt;
Conclusion&lt;/h2&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
The above illustrations shows how OPENJSON can be used to parse JSON and shred data into relational tables.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
This method can be used to get data in JSON format from the applications and then parse and shred the data to populate the tables.&lt;/div&gt;
&lt;/div&gt;
</description><link>http://visakhm.blogspot.com/2016/07/whats-new-in-sql-2016-native-json.html</link><author>noreply@blogger.com (Visakh Murukesan)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOAi958tHqLYlCpM5c7H7kj7PcluLNFNT2qc4eM-_4U1WCd5OrwagTA5D4Zi_QuFTjmLUTg_9-2w8HAKJc7t9Ch88n3uWk9CenI5xsHqQ6UYPe3S9yhIeeDgvr-cJR-ECFvbJCS4S3h_Yi/s72-c/ss.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7998687752365941655.post-9165437372992161601</guid><pubDate>Tue, 05 Jul 2016 18:45:00 +0000</pubDate><atom:updated>2016-07-06T00:17:37.626+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Row cannot be located for updating. Some values may have been changed since it was last read</category><title>How to solve OPENQUERY MySQL Update Issue Using ODBC DSN</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
This blog explains an issue you&#39;re likely to face while executing a remote UPDATE query against a MySQL server over a linked server connection using ODBC DSN based connectionstring&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Scenario&lt;/h2&gt;
Recently I was working in a project where I required data to be transferred from a remote server and do some manipulations with it. The status column in the remote server table have to be updated later. The remote server in this case was MySQL server and we were using ODBC DSNs based connectionstring.&lt;br /&gt;
When we try to execute an update statement against the remote server as below&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;UPDATE t&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SET col1 = value1,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;col2 = value2&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;FROM OPENQUERY(LINKEDSERVERNAME,&#39;select col1,col2,col3 from mysqlserver.tablename&#39;) t&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;WHERE col3 = &amp;nbsp;value3&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
We got an error message as given below&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;OLE DB provider &quot;MSDASQL&quot; for linked server &quot;MYLINKEDSERVER&quot; returned message &quot;Row cannot be located for updating. Some values may have been changed since it was last read.&quot;.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;Msg 7343, Level 16, State 4, Line 1&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;The OLE DB provider &quot;MSDASQL&quot; for linked server &quot;MYLINKEDSERVER&quot; could not UPDATE table &quot;[MSDASQL]&quot;. The rowset was using optimistic concurrency and the value of a column has been changed after the containing row was last fetched or resynchronized&lt;/span&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Solution&lt;/h2&gt;
&lt;br /&gt;
We tried tweaking the update query but still was not able to overcome the error&lt;br /&gt;
I searched regarding the error and finally managed to get the solution from a forum.&lt;br /&gt;
The solution required tweaking a small setting in the ODBC DSN property as shown below&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAfi0f8TJpUeD-1_M4Cal2NE2hYALEGgEHqJD5aNEimpwkrIUFZ1EsREA74XM9ZjQHK-MTSy0TC3ZkK_UhyWITXope-dVgRigL2iFWvslUJz2cx0ewO0F0WRQsvAFkNhW0y8JeUBtB3gPH/s1600/ss.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAfi0f8TJpUeD-1_M4Cal2NE2hYALEGgEHqJD5aNEimpwkrIUFZ1EsREA74XM9ZjQHK-MTSy0TC3ZkK_UhyWITXope-dVgRigL2iFWvslUJz2cx0ewO0F0WRQsvAFkNhW0y8JeUBtB3gPH/s400/ss.png&quot; width=&quot;298&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Once we set the Return matched rows instead of affected rows option the UPDATE query executed successfully.&lt;br /&gt;
This setting will allow the updating of values in MySQL to the fields which has a value already.&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Conclusion&lt;/h2&gt;
&lt;div&gt;
From the above illustration we can see that this setting will prevent the error happening in remote query updates due to optimistic concurrency setting.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
Hopefully this should help someone who is facing the same issue to get around the issue.&lt;/div&gt;
&lt;/div&gt;
</description><link>http://visakhm.blogspot.com/2016/07/how-to-solve-openquery-mysql-update.html</link><author>noreply@blogger.com (Visakh Murukesan)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAfi0f8TJpUeD-1_M4Cal2NE2hYALEGgEHqJD5aNEimpwkrIUFZ1EsREA74XM9ZjQHK-MTSy0TC3ZkK_UhyWITXope-dVgRigL2iFWvslUJz2cx0ewO0F0WRQsvAFkNhW0y8JeUBtB3gPH/s72-c/ss.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7998687752365941655.post-6187534138779269276</guid><pubDate>Mon, 27 Jun 2016 15:32:00 +0000</pubDate><atom:updated>2016-06-27T21:02:02.512+05:30</atom:updated><title>Whats New in SQL 2016 - Native JSON Function Support - Generating JSON documents using FOR JSON clause</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
One of the most sought after feature that got included in SQL 2016 is the native support for JSON data in Transact SQL. JSON has become kind of de-facto standard for data transfer in web applications these days. As such it makes it really awesome to know that you can generate JSON directly from the relational database using native SQL querying.&lt;br /&gt;
SQL 2016 has introduced &amp;nbsp;FOR JSON clause &amp;nbsp;which can be used to generate &amp;nbsp;JSON documents from relational database tables.&lt;br /&gt;
For people who have already worked with XML data it would be much easier as the syntax would be mostly similar to that of XML functions.&lt;br /&gt;
This blog article is the first in the series on the native JSON support in SQL 2016 and &amp;nbsp;explains on how JSON documents can be generated from relational tables using the FOR JSON construct.&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Illustration&lt;/h2&gt;
&lt;div&gt;
For the sake of this article consider the below table&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;declare @Items table&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;ItemID int,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;ItemDesc varchar(100),&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;Unitprice decimal(10,2)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;insert @Items&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;values(101,&#39;Monitor CRT 18&quot;&#39;,200),&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;(110,&#39;Printer Catridge&#39;,112),&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;(112,&#39;Copier Ink&#39;,20),&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;(123,&#39;Wireless Mouse&#39;,30)&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
There are two main options we can use with FOR JSON statement for constructing JSON documents.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
1. FOR JSON PATH&lt;/h2&gt;
&lt;div&gt;
The PATH option of the FOR XML construct provides flexibility to generate the JSON documents in the hierarchy we require.&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Basic Syntax&lt;/h3&gt;
&lt;div&gt;
Now to convert this relational data to JSON format we can use a simple query like below&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SELECT *&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;FROM @Items&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;FOR JSON PATH&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
The result will be as shown below&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;[&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;&amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;ItemID&quot;: 101,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;Monitor CRT 18\&quot;&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;Unitprice&quot;: 200&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;&amp;nbsp; },&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;&amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;ItemID&quot;: 110,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;Printer Catridge&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;Unitprice&quot;: 112&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;&amp;nbsp; },&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;&amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;ItemID&quot;: 112,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;Copier Ink&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;Unitprice&quot;: 20&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;&amp;nbsp; },&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;&amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;ItemID&quot;: 123,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;Wireless Mouse&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;Unitprice&quot;: 30&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;]&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Adding a ROOT key&lt;/h3&gt;
&lt;div&gt;
If you want to associate a root key name to it then you need to tweak the query as below&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SELECT *&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;FROM @Items&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;FOR JSON PATH,ROOT(&#39;Items&#39;)&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
And then output will become as below&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &quot;Items&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemID&quot;: 101,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;Monitor CRT 18\&quot;&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Unitprice&quot;: 200&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; },&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemID&quot;: 110,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;Printer Catridge&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Unitprice&quot;: 112&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; },&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemID&quot;: 112,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;Copier Ink&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Unitprice&quot;: 20&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; },&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemID&quot;: 123,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;Wireless Mouse&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Unitprice&quot;: 30&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; ]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
If you analyze the above output you can see that it returns an array of JSON objects within [] with key value as Items.&lt;/div&gt;
&lt;div&gt;
Now in case we are getting a single item from the query and want to return it as a single JSON document without the array wrapper we can use the optional clause WITHOUT_ARRAY_WRAPPER&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
ie like this&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SELECT TOP 1 *&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;FROM @Items&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;FOR JSON PATH,WITHOUT_ARRAY_WRAPPER&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
And we will get output as below&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
{&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &quot;ItemID&quot;: 101,&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &quot;ItemDesc&quot;: &quot;Monitor CRT 18\&quot;&quot;,&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &quot;Unitprice&quot;: 200&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
}&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Without the optional clause the output will be a single JSON object array as below&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
[{&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &quot;ItemID&quot;: 101,&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &quot;ItemDesc&quot;: &quot;Monitor CRT 18\&quot;&quot;,&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &quot;Unitprice&quot;: 200&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
}]&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;Handling of NULL values&amp;nbsp;&lt;/span&gt;&lt;/h2&gt;
&lt;div&gt;
Now lets see how NULL values are handled by FOR JSON construct&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Lets add two more rows to the table as per below script and check&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;declare @Items table&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;ItemID int,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;ItemDesc varchar(100),&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;Unitprice decimal(10,2)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;insert @Items&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;values(101,&#39;Monitor CRT 18&quot;&#39;,200),&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;(110,&#39;Printer Catridge&#39;,112),&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;(112,&#39;Copier Ink&#39;,20),&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;(123,&#39;Wireless Mouse&#39;,30),&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;(123,NULL,70),&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;(123,&#39;LED Monitor&#39;,NULL)&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SELECT &amp;nbsp;*&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;FROM @Items&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;FOR JSON PATH,ROOT(&#39;Items&#39;)&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;And by default output will be below&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &quot;Items&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemID&quot;: 101,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;Monitor CRT 18\&quot;&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Unitprice&quot;: 200&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; },&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemID&quot;: 110,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;Printer Catridge&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Unitprice&quot;: 112&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; },&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemID&quot;: 112,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;Copier Ink&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Unitprice&quot;: 20&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; },&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemID&quot;: 123,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;Wireless Mouse&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Unitprice&quot;: 30&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; },&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemID&quot;: 123,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Unitprice&quot;: 70&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; },&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemID&quot;: 123,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;LED Monitor&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; ]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
As you see from above be default it ignores the elements having NULL values in each JSON document.&lt;/div&gt;
&lt;div&gt;
If you want to include NULL values also in the resultset you need to specify optional parameter INCLUDE_NULL_VALUES&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SELECT &amp;nbsp;*&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;FROM @Items&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;FOR JSON PATH,ROOT(&#39;Items&#39;),INCLUDE_NULL_VALUES&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
And the output will modify as below&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &quot;Items&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemID&quot;: 101,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;Monitor CRT 18\&quot;&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Unitprice&quot;: 200&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; },&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemID&quot;: 110,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;Printer Catridge&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Unitprice&quot;: 112&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; },&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemID&quot;: 112,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;Copier Ink&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Unitprice&quot;: 20&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; },&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemID&quot;: 123,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;Wireless Mouse&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Unitprice&quot;: 30&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; },&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemID&quot;: 123,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: null,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Unitprice&quot;: 70&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; },&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemID&quot;: 123,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;LED Monitor&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Unitprice&quot;: null&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; ]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
Which will also include the elements with NULL values as you see from above&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;Generating Nested JSON documents&lt;/span&gt;&lt;/h3&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;Now lets consider the full set of tables as given below&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
declare @order table&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
(&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
OrderID int,&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
OrderDesc varchar(1000),&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
OrderDate datetime,&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
CustomerID int,&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
ShippedDate datetime,&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
WebOrder bit&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
)&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
declare @OrderItems table&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
(&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
OrderItemID int,&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
OrderID int,&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
ItemID int,&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
Qty int&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
)&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
declare @Items table&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
(&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
ItemID int,&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
ItemDesc varchar(100),&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
Unitprice decimal(10,2)&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
)&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
declare @Customers table&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
(&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
CustomerID int,&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
CustomerDesc varchar(100)&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
)&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
declare @SubItems table&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
(&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
SubItemID int,&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
ItemID int,&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
SubItemDesc varchar(100)&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
)&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
insert @Order&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
values (100001,&#39;Order 1&#39;,&#39;20130212&#39;,1004,&#39;20130220&#39;,0),&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
(100002,&#39;Order 2&#39;,&#39;20150624&#39;,1002,&#39;20150630&#39;,0),&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
(100005,&#39;Order 5&#39;,&#39;20160517&#39;,1012,&#39;20160522&#39;,1)&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
insert @OrderItems&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
values (10005,100001,123,10),&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
(10007,100001,112,8),&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
(10009,100002,110,12),&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
(10011,100005,101,28)&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
insert @Items&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
values(101,&#39;Monitor CRT 18&quot;&#39;,200),&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
(110,&#39;Printer Catridge&#39;,112),&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
(112,&#39;Copier Ink&#39;,20),&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
(123,&#39;Wireless Mouse&#39;,30)&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
insert @SubItems&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
values (118,110,&#39;SP1&#39;),&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
(123,110,&#39;SP3&#39;),&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
(130,112,&#39;SP5&#39;),&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
(140,112,&#39;SP12&#39;),&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
(144,123,&#39;SP17&#39;)&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
insert @Customers&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
values (1002,&#39;ABC inc&#39;),&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
(1004,&#39;KBC Associates&#39;),&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
(1012,&#39;AAM &amp;amp; Co&#39;)&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;color: blue; font-size: small;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
There are two ways to generate nested JSON structure from the above data&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
The straightforward way is to specify the nesting level &amp;nbsp;as an alias in the FOR JSON query.&lt;/div&gt;
&lt;div&gt;
The query will look like this&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SELECT o.OrderDesc,o.OrderDate,o.ShippedDate,o.WebOrder,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;oi.Qty AS &#39;OrderItem.OrderQty&#39;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;i.ItemDesc AS &#39;OrderItem.Item.ItemDesc&#39;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;i.Unitprice AS &#39;OrderItem.Item.UnitPrice&#39;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;s.SubItemDesc AS &#39;OrderItem.Item.SubItem.SubItemDesc&#39;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;c.CustomerDesc AS &#39;Customer.CustomerDesc&#39;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;FROM @order o&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;INNER JOIN @OrderItems oi&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;ON oi.OrderID = o.OrderID&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;INNER JOIN @Items i&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;ON i.ItemID = oi.ItemID&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;INNER JOIN @Customers c&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;ON c.CustomerID = o.CustomerID&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;INNER JOIN @SubItems s&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;ON s.ItemID = i.ItemID&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;FOR JSON PATH,ROOT(&#39;Orders&#39;)&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;And the resulting JSON will be as below&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &quot;Orders&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderDesc&quot;: &quot;Order 1&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderDate&quot;: &quot;2013-02-12T00:00:00&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ShippedDate&quot;: &quot;2013-02-20T00:00:00&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;WebOrder&quot;: false,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderItem&quot;: {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderQty&quot;: 10,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Item&quot;: {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;Wireless Mouse&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;UnitPrice&quot;: 30,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SubItem&quot;: {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SubItemDesc&quot;: &quot;SP17&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; },&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Customer&quot;: {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;CustomerDesc&quot;: &quot;KBC Associates&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; },&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderDesc&quot;: &quot;Order 1&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderDate&quot;: &quot;2013-02-12T00:00:00&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ShippedDate&quot;: &quot;2013-02-20T00:00:00&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;WebOrder&quot;: false,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderItem&quot;: {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderQty&quot;: 8,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Item&quot;: {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;Copier Ink&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;UnitPrice&quot;: 20,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SubItem&quot;: {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SubItemDesc&quot;: &quot;SP5&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; },&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Customer&quot;: {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;CustomerDesc&quot;: &quot;KBC Associates&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; },&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderDesc&quot;: &quot;Order 1&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderDate&quot;: &quot;2013-02-12T00:00:00&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ShippedDate&quot;: &quot;2013-02-20T00:00:00&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;WebOrder&quot;: false,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderItem&quot;: {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderQty&quot;: 8,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Item&quot;: {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;Copier Ink&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;UnitPrice&quot;: 20,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SubItem&quot;: {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SubItemDesc&quot;: &quot;SP12&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; },&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Customer&quot;: {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;CustomerDesc&quot;: &quot;KBC Associates&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; },&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderDesc&quot;: &quot;Order 2&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderDate&quot;: &quot;2015-06-24T00:00:00&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ShippedDate&quot;: &quot;2015-06-30T00:00:00&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;WebOrder&quot;: false,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderItem&quot;: {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderQty&quot;: 12,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Item&quot;: {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;Printer Catridge&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;UnitPrice&quot;: 112,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SubItem&quot;: {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SubItemDesc&quot;: &quot;SP1&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; },&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Customer&quot;: {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;CustomerDesc&quot;: &quot;ABC inc&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; },&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderDesc&quot;: &quot;Order 2&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderDate&quot;: &quot;2015-06-24T00:00:00&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ShippedDate&quot;: &quot;2015-06-30T00:00:00&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;WebOrder&quot;: false,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderItem&quot;: {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderQty&quot;: 12,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Item&quot;: {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;Printer Catridge&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;UnitPrice&quot;: 112,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SubItem&quot;: {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SubItemDesc&quot;: &quot;SP3&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; },&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Customer&quot;: {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;CustomerDesc&quot;: &quot;ABC inc&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; ]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
As you see from above result the JSON document is generated in nested order with each level coming under corresponding parent level as specified by the alias names used.&lt;/div&gt;
&lt;div&gt;
But one thing to note here is that the entire parent hierarchy gets repeated for each instance of the child document. If you want to avoid this then you need to return the child elements as an array within parent element.&lt;/div&gt;
&lt;div&gt;
Inorder to get it in array format the query will look like this&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SELECT o.OrderDesc,o.OrderDate,o.ShippedDate,o.WebOrder,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;(SELECT Qty AS OrderQty,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;(SELECT ItemDesc,Unitprice,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;(SELECT SubItemDesc&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;FROM @SubItems&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;WHERE ItemID = i.ItemID&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;FOR JSON PATH) AS SUbItem&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;FROM @Items i&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;WHERE ItemID = oi.ItemID&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;FOR JSON PATH) AS Item&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;FROM @OrderItems oi&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;WHERE oi.OrderID = o.OrderID&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;FOR JSON PATH) AS OrderItems,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;(SELECT CustomerDesc&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;FROM @Customers&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;WHERE CustomerID = o.CustomerID&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;FOR JSON PATH)AS Customer&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;FROM @order o&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;FOR JSON PATH,ROOT(&#39;Orders&#39;)&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
As you see the query itself will include nested subqueries in that case&lt;/div&gt;
&lt;div&gt;
Check the result and you will see child documents coming in array format without parent getting repeated as below&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &quot;Orders&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderDesc&quot;: &quot;Order 1&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderDate&quot;: &quot;2013-02-12T00:00:00&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ShippedDate&quot;: &quot;2013-02-20T00:00:00&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;WebOrder&quot;: false,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderItems&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderQty&quot;: 10,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Item&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;Wireless Mouse&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Unitprice&quot;: 30,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SUbItem&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SubItemDesc&quot;: &quot;SP17&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; },&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderQty&quot;: 8,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Item&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;Copier Ink&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Unitprice&quot;: 20,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SUbItem&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SubItemDesc&quot;: &quot;SP5&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; },&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SubItemDesc&quot;: &quot;SP12&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; ],&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Customer&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;CustomerDesc&quot;: &quot;KBC Associates&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; ]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; },&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderDesc&quot;: &quot;Order 2&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderDate&quot;: &quot;2015-06-24T00:00:00&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ShippedDate&quot;: &quot;2015-06-30T00:00:00&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;WebOrder&quot;: false,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderItems&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderQty&quot;: 12,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Item&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;Printer Catridge&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Unitprice&quot;: 112,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SUbItem&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SubItemDesc&quot;: &quot;SP1&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; },&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SubItemDesc&quot;: &quot;SP3&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; ],&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Customer&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;CustomerDesc&quot;: &quot;ABC inc&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; ]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; },&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderDesc&quot;: &quot;Order 5&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderDate&quot;: &quot;2016-05-17T00:00:00&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ShippedDate&quot;: &quot;2016-05-22T00:00:00&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;WebOrder&quot;: true,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderItems&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderQty&quot;: 28,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Item&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;Monitor CRT 18\&quot;&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Unitprice&quot;: 200&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; ],&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Customer&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;CustomerDesc&quot;: &quot;AAM &amp;amp; Co&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; ]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; ]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
2. FOR JSON AUTO&lt;/h2&gt;
&lt;div&gt;
As the name implies AUTO mode of the FOR JSON construct generates the JSON documents automatically based on the hierarchy we specify in the query&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
To see this in action lets use the same query we used above in AUTO mode&lt;/div&gt;
&lt;div&gt;
The query will look like this&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SELECT o.OrderDesc,o.OrderDate,o.ShippedDate,o.WebOrder,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;oi.Qty,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;i.ItemDesc,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;i.Unitprice,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;s.SubItemDesc,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;c.CustomerDesc&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;FROM @order o&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;INNER JOIN @OrderItems oi&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;ON oi.OrderID = o.OrderID&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;INNER JOIN @Items i&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;ON i.ItemID = oi.ItemID&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;INNER JOIN @Customers c&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;ON c.CustomerID = o.CustomerID&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;INNER JOIN @SubItems s&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;ON s.ItemID = i.ItemID&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;FOR JSON AUTO,ROOT(&#39;Orders&#39;)&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
The resulting JSON would be as below&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &quot;Orders&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderDesc&quot;: &quot;Order 1&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderDate&quot;: &quot;2013-02-12T00:00:00&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ShippedDate&quot;: &quot;2013-02-20T00:00:00&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;WebOrder&quot;: false,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;oi&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Qty&quot;: 10,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;i&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;Wireless Mouse&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Unitprice&quot;: 30,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;s&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SubItemDesc&quot;: &quot;SP17&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;c&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;CustomerDesc&quot;: &quot;KBC Associates&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; },&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Qty&quot;: 8,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;i&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;Copier Ink&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Unitprice&quot;: 20,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;s&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SubItemDesc&quot;: &quot;SP5&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;c&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;CustomerDesc&quot;: &quot;KBC Associates&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; },&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SubItemDesc&quot;: &quot;SP12&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;c&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;CustomerDesc&quot;: &quot;KBC Associates&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; ]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; },&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderDesc&quot;: &quot;Order 2&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderDate&quot;: &quot;2015-06-24T00:00:00&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ShippedDate&quot;: &quot;2015-06-30T00:00:00&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;WebOrder&quot;: false,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;oi&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Qty&quot;: 12,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;i&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;Printer Catridge&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Unitprice&quot;: 112,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;s&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SubItemDesc&quot;: &quot;SP1&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;c&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;CustomerDesc&quot;: &quot;ABC inc&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; },&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SubItemDesc&quot;: &quot;SP3&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;c&quot;: [&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;CustomerDesc&quot;: &quot;ABC inc&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; ]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&amp;nbsp; ]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #38761d; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
As you see from the above the JSON structure is automatically generated based on the query sequence. We dont have much control over JSON structure generated.&lt;/div&gt;
&lt;div&gt;
Now lets see how AUTO mode behaves for the second query&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
{&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &quot;Orders&quot;: [&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderDesc&quot;: &quot;Order 1&quot;,&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderDate&quot;: &quot;2013-02-12T00:00:00&quot;,&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ShippedDate&quot;: &quot;2013-02-20T00:00:00&quot;,&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;WebOrder&quot;: false,&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderItems&quot;: [&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderQty&quot;: 10,&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Item&quot;: [&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;Wireless Mouse&quot;,&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Unitprice&quot;: 30,&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SUbItem&quot;: [&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SubItemDesc&quot;: &quot;SP17&quot;&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ]&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ]&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; },&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderQty&quot;: 8,&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Item&quot;: [&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;Copier Ink&quot;,&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Unitprice&quot;: 20,&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SUbItem&quot;: [&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SubItemDesc&quot;: &quot;SP5&quot;&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; },&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SubItemDesc&quot;: &quot;SP12&quot;&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ]&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ]&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; ],&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Customer&quot;: [&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;CustomerDesc&quot;: &quot;KBC Associates&quot;&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; ]&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; },&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderDesc&quot;: &quot;Order 2&quot;,&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderDate&quot;: &quot;2015-06-24T00:00:00&quot;,&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ShippedDate&quot;: &quot;2015-06-30T00:00:00&quot;,&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;WebOrder&quot;: false,&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderItems&quot;: [&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderQty&quot;: 12,&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Item&quot;: [&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;Printer Catridge&quot;,&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Unitprice&quot;: 112,&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SUbItem&quot;: [&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SubItemDesc&quot;: &quot;SP1&quot;&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; },&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;SubItemDesc&quot;: &quot;SP3&quot;&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ]&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ]&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; ],&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Customer&quot;: [&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;CustomerDesc&quot;: &quot;ABC inc&quot;&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; ]&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; },&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderDesc&quot;: &quot;Order 5&quot;,&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderDate&quot;: &quot;2016-05-17T00:00:00&quot;,&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ShippedDate&quot;: &quot;2016-05-22T00:00:00&quot;,&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;WebOrder&quot;: true,&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderItems&quot;: [&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;OrderQty&quot;: 28,&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Item&quot;: [&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ItemDesc&quot;: &quot;Monitor CRT 18\&quot;&quot;,&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Unitprice&quot;: 200&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ]&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; ],&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;Customer&quot;: [&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;CustomerDesc&quot;: &quot;AAM &amp;amp; Co&quot;&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; ]&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&amp;nbsp; ]&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
}&lt;/div&gt;
&lt;div style=&quot;color: #38761d; font-size: small;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Conclusion&lt;/h2&gt;
&lt;/div&gt;
&lt;div&gt;
As you see from all the above illustrations FOR JSON provides a convenient way of generating JSON documents from relational table data.&lt;br /&gt;
Based on flexibility you need, you can use PATH or the AUTO mode along with FOR JSON for generating the JSON documents in the required format.&lt;br /&gt;
See you all with the next article in the series which will explain on how to extract data from JSON documents to relational tables. Till then happy coding with the sample scripts above. Feel free to revert for any clarifications.&lt;/div&gt;
&lt;/div&gt;
</description><link>http://visakhm.blogspot.com/2016/06/whats-new-in-sql-2016-native-json.html</link><author>noreply@blogger.com (Visakh Murukesan)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7998687752365941655.post-1169850679744199354</guid><pubDate>Fri, 17 Jun 2016 16:04:00 +0000</pubDate><atom:updated>2016-06-17T21:34:54.716+05:30</atom:updated><title>Whats New in SSIS 2016 - Expose SSIS Package Data Externally as a View</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Introduction&lt;/h2&gt;
&lt;div&gt;
SQL 2016 has brought in lots of new and exciting features on the plate. One of the pretty cool feature that was added to SSIS in SQL 2016 is the ability to expose the data directly as a SQLServer database view object which can be accessed using T-SQL queries.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
This is made possible by the introduction of two new components&lt;/div&gt;
&lt;div&gt;
1. A new linked server provider &lt;b&gt;SSISOLEDB &lt;/b&gt;which is capable of exposing the SSIS data to SQLServer database&lt;/div&gt;
&lt;div&gt;
2. A new data flow component called &lt;b&gt;Data Streaming Destination&lt;/b&gt; which will stream the data to be consumed through the linked server based on the above provider&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
Once you&#39;ve installed SQL 2016 you can connect to the instance using management studio and when you expand the Server Objects - Linked Servers - Providers you can see this new provider listed as per below&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKTbDrVUZO7wIwbml38G2CiElwDwnG0TIJbb3VNdZx7DkL-WXTlKf5-iZd-g0XuduNAGr0SBrIKOfyDp_Mm5uo5Ouqia0LGhN-oJjP8TURH7PvKzZhB_GIf8seXduKbwuzrqzkftsDEuvs/s1600/ss.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKTbDrVUZO7wIwbml38G2CiElwDwnG0TIJbb3VNdZx7DkL-WXTlKf5-iZd-g0XuduNAGr0SBrIKOfyDp_Mm5uo5Ouqia0LGhN-oJjP8TURH7PvKzZhB_GIf8seXduKbwuzrqzkftsDEuvs/s320/ss.png&quot; width=&quot;265&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Similarly you can launch SSDT (SQLServer Data Tools) 2015 and start an Integration Services project and create a sample package with a single data flow task. Inside data flow task tab you can see the new destination component available&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbxYai3wlYra-0qmT5FHNo4O36wc1e1iZly7ZN5aBFX_ra0jmKweRvRLkSX-YBgFgIUUrCbw18cut063PXeu0xyTVvmVjuf_qWL5H0VY1m8yUPAnxgrpIIY3czw9OFw9fy-ftxA1fofzE0/s1600/ss.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;117&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbxYai3wlYra-0qmT5FHNo4O36wc1e1iZly7ZN5aBFX_ra0jmKweRvRLkSX-YBgFgIUUrCbw18cut063PXeu0xyTVvmVjuf_qWL5H0VY1m8yUPAnxgrpIIY3czw9OFw9fy-ftxA1fofzE0/s400/ss.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Now that we have seen the two components lets see how they can be used together for exposing SSIS data as a SQLServer database object.&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Illustration&lt;/h2&gt;
Consider the scenario where we have data coming from different sources which needs to be exposed to &amp;nbsp;our database as an object.&lt;br /&gt;
For the sake of this article lets consider the below scenario&lt;br /&gt;
1. Customer details coming from a SQL database&lt;br /&gt;
2. Customet Satisfaction score data coming from an Excel spreadsheet&lt;br /&gt;
&lt;br /&gt;
The requirement is to merge the data from the above sources to be accessed within third database most often a datawarehouse for analytical and reporting needs.&lt;br /&gt;
For this kind of requirement the obvious way to approach is to create a SSIS package which can extract the required data from the various source and do the merge operation based on the related columns.&lt;br /&gt;
Such a package for the above case would look like this&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiTCPj8smjOjexFx61yAZYvqCowsP92Jba2ERzO4iiJrny5jDKdXFtR_2M9f69h_eiIElPOqtVP3uYiiFEEyGKOImS6GQ_apkRpU9p_yRPzo0rAlAuDq3K-WOcKnYANuVzS3biGVoMt4WeE/s1600/ss.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;131&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiTCPj8smjOjexFx61yAZYvqCowsP92Jba2ERzO4iiJrny5jDKdXFtR_2M9f69h_eiIElPOqtVP3uYiiFEEyGKOImS6GQ_apkRpU9p_yRPzo0rAlAuDq3K-WOcKnYANuVzS3biGVoMt4WeE/s400/ss.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
The data flow tasks will look like below&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQi3cszOtw7wEb8hbzznwFn1LB4Dnti9paO-lfxKS-yyw9i78y9uXEj-jBbfXu43pV-7D8EqGJGfpCcLvCBTiS7qn_ZNKe4OWdetpjSeNgca5M-sumvARk67yqpETcp0YtGiLAcadVSB53/s1600/ss.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;296&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQi3cszOtw7wEb8hbzznwFn1LB4Dnti9paO-lfxKS-yyw9i78y9uXEj-jBbfXu43pV-7D8EqGJGfpCcLvCBTiS7qn_ZNKe4OWdetpjSeNgca5M-sumvARk67yqpETcp0YtGiLAcadVSB53/s400/ss.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
The sources involved here are SQL database which has the Customer details as per below&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;CREATE TABLE OrderDetails&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;OrderID int IDENTITY(1,1),&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;CustomerName varchar(100),&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;CustomerEMail varchar(100),&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;OrderDesc varchar(100),&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;OrderPrice Decimal(10,2),&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;OrderDate datetime&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;INSERT OrderDetails (CustomerName,CustomerEMail,OrderDesc,OrderPrice,OrderDate)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;VALUES (&#39;Customer 1&#39;,&#39;abc@xyz.com&#39;,&#39;Order ABC&#39;,130,&#39;20151104&#39;),&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;(&#39;Customer 2&#39;,&#39;kytrtetet@treby.com&#39;,&#39;Order PQR&#39;,2150.50,&#39;20151203&#39;),&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;(&#39;Customer 5&#39;,&#39;887rtert767@hakii.co.hk&#39;,&#39;Order for DEF and Co&#39;,1785,&#39;20160112&#39;),&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;(&#39;Customer 7&#39;,&#39;hjgjh@kaz.co.in&#39;,&#39;M/S Bhavya Comp Ltd&#39;,890,&#39;20160120&#39;),&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;(&#39;Customer 9&#39;,&#39;ewrewrr@oiuiiuo.co.in&#39;,&#39;XYZ&#39;,1125,&#39;20160205&#39;),&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;(&#39;Customer 1&#39;,&#39;abc@xyz.com&#39;,&#39;DEF&#39;,3400,&#39;20160322&#39;),&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;(&#39;Customer 9&#39;,&#39;ewrewrr@oiuiiuo.co.in&#39;,&#39;MNU&#39;,215,&#39;20160312&#39;),&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;(&#39;Customer 14&#39;,&#39;ytrytr@terry.co.in&#39;,&#39;PUK&#39;,345,&#39;20160415&#39;),&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;(&#39;Kirby Stevens&#39;,&#39;kirby.stevens@jackoss.co.eu&#39;,&#39;WKP&#39;,2300,&#39;20160420&#39;),&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;(&#39;Kerney Michelle&#39;,&#39;kerney@hkrky.co.ae&#39;,&#39;VER&#39;,485,&#39;20160512&#39;),&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;(&#39;Customer 1&#39;,&#39;abc@xyz.com&#39;,&#39;RTU&#39;,1320,&#39;20160514&#39;),&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;(&#39;Mark Bowerman&#39;,&#39;mark.2134@kayko.com&#39;,&#39;BJY&#39;,1130,&#39;20160603&#39;),&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;(&#39;Customer 9&#39;,&#39;ewrewrr@oiuiiuo.co.in&#39;,&#39;SAR&#39;,765,&#39;20160610&#39;)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: xx-small;&quot;&gt;And the query used is as below to get the count and total value of orders per customer&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SELECT CustomerName,&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;CustomerEMail,&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;COUNT(OrderDesc) AS OrderCount,&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SUM(OrderPrice) AS TotalOrderPrice&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;FROM OrderDetails&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;GROUP BY CustomerName,&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;CustomerEMail&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;ORDER BY CustomerEMail&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Source 2 is an excel spreadsheet with customer satisfaction data as below&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjs9OC2EVQb1NIFUiXhfbG-CBkkm3Dk2s6ok2Ys3BOaIb9XGD1CEr_5RMZGPSW59Ie_3Nb-2zv0y7GblUG-tcY3OPZbxAngGiLh00G07OBIXAtWYWmDVOZqwl2TDl6QGAWEBRps0xqfokDF/s1600/ss.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjs9OC2EVQb1NIFUiXhfbG-CBkkm3Dk2s6ok2Ys3BOaIb9XGD1CEr_5RMZGPSW59Ie_3Nb-2zv0y7GblUG-tcY3OPZbxAngGiLh00G07OBIXAtWYWmDVOZqwl2TDl6QGAWEBRps0xqfokDF/s400/ss.png&quot; width=&quot;395&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
And for this illustration we use the above query to get the average customer satisfaction score and &amp;nbsp;response count&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SELECT email,&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;AVG(satscore) AS AvgSatScore,&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;COUNT(*) AS responseCount&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;FROM `Sheet1$`&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;GROUP BY email&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;ORDER BY email&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
From these two sources of data would be merged based on the common columns between the two resultsets as shown below&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYpETs5wQu8A9WqQ2c9ziXrEbl3KSRUK0o96vUfu5DbiuUgsH_1wm1wVt7KP6C__qRQqmu_IPd1ZTJuChl2JhZb0c7rzxsaP9N0K0AkFrkqern0Jc9kYEweZ1gMl-lOipiWVjb59uEidbJ/s1600/ss.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;322&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYpETs5wQu8A9WqQ2c9ziXrEbl3KSRUK0o96vUfu5DbiuUgsH_1wm1wVt7KP6C__qRQqmu_IPd1ZTJuChl2JhZb0c7rzxsaP9N0K0AkFrkqern0Jc9kYEweZ1gMl-lOipiWVjb59uEidbJ/s400/ss.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Once this is done we would get the required resultset. Now inorder to stream the resultset we will use Data Streaming Destination component and include the required columns to be accessed through the exposed view.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjutfqeohEof2qkE3nPPhYcDE1n6kuslYF4L5NEAfPdXq5GoXknOG_Pq-ZiU7iMp6Iww6TrMNDzgjlIxX-f3l9kNVU2kgIBDzhMZChaBKuFn86MUbSIarNHoemeywnvqgItRUzLVfGko7Gr/s1600/ss.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;301&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjutfqeohEof2qkE3nPPhYcDE1n6kuslYF4L5NEAfPdXq5GoXknOG_Pq-ZiU7iMp6Iww6TrMNDzgjlIxX-f3l9kNVU2kgIBDzhMZChaBKuFn86MUbSIarNHoemeywnvqgItRUzLVfGko7Gr/s400/ss.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Data Streaming Destination will include the required columns as shown above&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Once this is done we need to deploy the package to the Integration Services Catalog.&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
The package will get deployed to the Integration Services Server as shown below&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgm-OHsHg90mHVubEQoTpbjyaRMTdMtMrdG-Liq7Ln2A0hawTiGaOZ2h6ICQchxAnJga3SNa7xcETNwUK4YdHcF8W6bHIF1h7I7_thsTKd1bhqTWGQnEyC4W5v1gmXO64JPSuC_RvTAV5_k/s1600/ss.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgm-OHsHg90mHVubEQoTpbjyaRMTdMtMrdG-Liq7Ln2A0hawTiGaOZ2h6ICQchxAnJga3SNa7xcETNwUK4YdHcF8W6bHIF1h7I7_thsTKd1bhqTWGQnEyC4W5v1gmXO64JPSuC_RvTAV5_k/s320/ss.png&quot; width=&quot;313&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Once this is done we need to stream the package data as a view within a database in the associated instance.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
This can be done using &lt;b&gt;data feed publishing wizard&lt;/b&gt; which comes with the SQL 2016 installation.&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNya1qE_24KcTaW6EZe7KUi6NBuA-GuYAucC6AIDcPlX616FkMeRZknKIhRZPvUP548-X81jlw3Z3fcb7b3gLI83S4AkFCnRZjcHk-Vj9tJ3GROIpLoapJKrRMyQES6z8nmwXqB6xaoHUe/s1600/ss.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;200&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNya1qE_24KcTaW6EZe7KUi6NBuA-GuYAucC6AIDcPlX616FkMeRZknKIhRZPvUP548-X81jlw3Z3fcb7b3gLI83S4AkFCnRZjcHk-Vj9tJ3GROIpLoapJKrRMyQES6z8nmwXqB6xaoHUe/s320/ss.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
We can launch data feed publishing wizard and it will come up with the below window&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiw5cmI613YfecY2AjZwO8YdK8ZzMiUT-7E30ZGiCT7yK8OPQNZnBmRTt41mnSodyy8wlNNQwwGuEH-vtZVxnXoyuMAJo3Rx1dHU2FBLjXO6Fw2197tFBPuqbBx9HsAft_M7LNySIPQ66ax/s1600/ss.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;370&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiw5cmI613YfecY2AjZwO8YdK8ZzMiUT-7E30ZGiCT7yK8OPQNZnBmRTt41mnSodyy8wlNNQwwGuEH-vtZVxnXoyuMAJo3Rx1dHU2FBLjXO6Fw2197tFBPuqbBx9HsAft_M7LNySIPQ66ax/s400/ss.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Click Next and it will ask you to select the server and package to be published&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Once selected it will also give you the option to modify the default values set for the connection managers and parameters in the package which I&#39;m not changing for this example.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFlzbJbsZZ1cozIxgEH3PFBuIAW0zV9HcZS-bEhKC7iOpFhChogF-D2YNf-H5AkgUIk0Ru85LlPWA1EIQvleB4LrL_xNC9fCl0gfT48xRGdzY2C2eCnZl_QRDY2tdACYfIBMr5oT4fT1k4/s1600/ss.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;353&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFlzbJbsZZ1cozIxgEH3PFBuIAW0zV9HcZS-bEhKC7iOpFhChogF-D2YNf-H5AkgUIk0Ru85LlPWA1EIQvleB4LrL_xNC9fCl0gfT48xRGdzY2C2eCnZl_QRDY2tdACYfIBMr5oT4fT1k4/s400/ss.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Clicking Next will bring it to Publish settings screen where we will specify the view name through which we need to expose the package data.&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2GE9cppr9KKLo6y3jYNVDOTc6Gm78Lc3pdhJboXUsfRns1B98nyhsmpYpfO4C2LMIC0HkXSaFovB_tqU2uRxeOBv6R7vbe2O9953zMhzEY4GyMFyh9ha7tQCiGmaSkDdWgGyqSP67jr5N/s1600/ss.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;337&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2GE9cppr9KKLo6y3jYNVDOTc6Gm78Lc3pdhJboXUsfRns1B98nyhsmpYpfO4C2LMIC0HkXSaFovB_tqU2uRxeOBv6R7vbe2O9953zMhzEY4GyMFyh9ha7tQCiGmaSkDdWgGyqSP67jr5N/s400/ss.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
One thing to note here is that Use 32Bit Runtime is set to True as one of the sources involved here is an Excel spreadsheet and the ACE driver installed is of 32 bit version in the server. In case you&#39;ve the 64 bit version installed then you don&#39;t need to tweak this setting.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
On clicking Next it goes to the validation screen and validates the various steps involved&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYUzag8I2shtHNvWBNBunaMBzAKKgq_vEoc6gbRtwSb5RKZbSx2CQZ0BGkRVmGa5_z6UCwF7VSbHHe269H5UVSu61tCTqVf4VtvhhEvecJPHSjaED23ip16RIhVgsE3rIFA8tGOSEXdoox/s1600/ss.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;361&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYUzag8I2shtHNvWBNBunaMBzAKKgq_vEoc6gbRtwSb5RKZbSx2CQZ0BGkRVmGa5_z6UCwF7VSbHHe269H5UVSu61tCTqVf4VtvhhEvecJPHSjaED23ip16RIhVgsE3rIFA8tGOSEXdoox/s400/ss.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Click on Next and finally click Finish to publish the package as a view&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHl9oKOdou3_u3aVSfdjDSR_2vnKJZ6XNTpTNTVHOQaqOeKUaghrmZw7wtyNMPOUFQNFMLyk2bXB50UgO0ebfYy_F7AdF3Rm4ezeVBS1JsREIwtctEVW6sN3WPsiUwY3VDXKIoD33KFIX9/s1600/ss.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;273&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHl9oKOdou3_u3aVSfdjDSR_2vnKJZ6XNTpTNTVHOQaqOeKUaghrmZw7wtyNMPOUFQNFMLyk2bXB50UgO0ebfYy_F7AdF3Rm4ezeVBS1JsREIwtctEVW6sN3WPsiUwY3VDXKIoD33KFIX9/s400/ss.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Once publishing is done you can connect to the server instance through SQL Management Studio and go to the specified database and expand views to see the view you published&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFWqAydPFjX72bSt9ttTmT-XaY3Q2OKBAlLoOQRGeFw4h0hQK-5cORc1FQniFDRADeMfntF1egz2Z6gDyVaiYTCy5jj6NLsfKcTHFCBi19F3I_1y16-WLhP7TxGzAPWhbg9IeBRP1QN2c2/s1600/ss.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFWqAydPFjX72bSt9ttTmT-XaY3Q2OKBAlLoOQRGeFw4h0hQK-5cORc1FQniFDRADeMfntF1egz2Z6gDyVaiYTCy5jj6NLsfKcTHFCBi19F3I_1y16-WLhP7TxGzAPWhbg9IeBRP1QN2c2/s400/ss.png&quot; width=&quot;360&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Right click and Select data from the view and it will execute the package on the background and will provide you with the below result&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDl7T_Cf2wOuVraKTn_ner0V49vd7E4_TFDgGnx1BVrGKLwjhonyR9Zpui__M_RSCKscSkT9zKRW1VOeCtZCZg5G3QgnDWceurOHVatCeP1PiSFuCOO8ShrlzL0wNN4E6XcGN7XjULDHZ9/s1600/ss.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;206&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDl7T_Cf2wOuVraKTn_ner0V49vd7E4_TFDgGnx1BVrGKLwjhonyR9Zpui__M_RSCKscSkT9zKRW1VOeCtZCZg5G3QgnDWceurOHVatCeP1PiSFuCOO8ShrlzL0wNN4E6XcGN7XjULDHZ9/s400/ss.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
You can confirm this by expanding Integration Services Catalog and finding the package within your deployed project and then right clicking and choosing the All Executions report which will show the log for successful execution of the package when view gets referred in the query&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiyJxTHHn3BU1Rcr5dknAPol-y7qxfFYVqOBvTbMe89n2qDxfGGmSTPdlie_Bm_l8WEe_LdbqBkY_1QzWjK9y3DQ7MfrLLyN_LJeWhDoWuTlNYoR1i4YOMnfYcmj_PP5qNyMx_-HBBUp8Mj/s1600/ss.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;27&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiyJxTHHn3BU1Rcr5dknAPol-y7qxfFYVqOBvTbMe89n2qDxfGGmSTPdlie_Bm_l8WEe_LdbqBkY_1QzWjK9y3DQ7MfrLLyN_LJeWhDoWuTlNYoR1i4YOMnfYcmj_PP5qNyMx_-HBBUp8Mj/s400/ss.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2 style=&quot;clear: both; text-align: left;&quot;&gt;
Conclusion&lt;/h2&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
As shown by the illustration above you can use the new data feed publishing wizard available in SQL 2016 for exposing a SSIS package resultset as a view object within an associated relational database. This is a very useful feature which can be used for publishing a resultset consisting of data extracted from a variety of sources.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</description><link>http://visakhm.blogspot.com/2016/06/whats-new-in-ssis-2016-expose-ssis.html</link><author>noreply@blogger.com (Visakh Murukesan)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKTbDrVUZO7wIwbml38G2CiElwDwnG0TIJbb3VNdZx7DkL-WXTlKf5-iZd-g0XuduNAGr0SBrIKOfyDp_Mm5uo5Ouqia0LGhN-oJjP8TURH7PvKzZhB_GIf8seXduKbwuzrqzkftsDEuvs/s72-c/ss.png" height="72" width="72"/><thr:total>0</thr:total></item></channel></rss>