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

<channel>
	<title>SQL For XML Explicit - MSSQL Query</title>
	<atom:link href="https://mssqlquery.com/tag/sql-for-xml-explicit/feed" rel="self" type="application/rss+xml" />
	<link>https://mssqlquery.com</link>
	<description>MSSQL and TSQL Programming and TSQL Examples</description>
	<lastBuildDate>Mon, 26 Sep 2022 17:38:10 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.3.1</generator>

<image>
	<url>https://mssqlquery.com/wp-content/uploads/2023/06/cropped-mssql-query-icon-32x32.png</url>
	<title>SQL For XML Explicit - MSSQL Query</title>
	<link>https://mssqlquery.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>For XML Explicit in SQL Server</title>
		<link>https://mssqlquery.com/for-xml-explicit-in-sql-server</link>
		
		<dc:creator><![CDATA[Yavuz Selim Kart]]></dc:creator>
		<pubDate>Sun, 07 Aug 2022 22:17:35 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[For XML Explicit]]></category>
		<category><![CDATA[For XML Explicit in SQL Server]]></category>
		<category><![CDATA[SQL For XML Explicit]]></category>
		<guid isPermaLink="false">https://mssqlquery.com/?p=1034</guid>

					<description><![CDATA[<p>Hello everyone, In this article, I will talk about the use of For XML Explicit in SQL Server. In SQL Server, For XML Explicit statement is used to output XML. The For XML Explicit statement is used with Tag and Parent statements. You might be a little confused when used&#46;&#46;&#46;</p>
<p>The post <a href="https://mssqlquery.com/for-xml-explicit-in-sql-server">For XML Explicit in SQL Server</a> first appeared on <a href="https://mssqlquery.com">MSSQL Query</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Hello everyone,</p>
<p>In this article, I will talk about the use of For XML Explicit in SQL Server.</p>
<p>In SQL Server, For XML Explicit statement is used to output XML. The For XML Explicit statement is used with Tag and Parent statements. You might be a little confused when used for the first time, but don&#8217;t give up right away. When you start to understand how it is used, you will find that it really works. Let&#8217;s examine the example usage using the Northwind database.</p>
<pre class="line-numbers"><code class="language-sql">SELECT 1 AS Tag,
       NULL AS Parent,
       e.EmployeeID AS [Employee!1!EmployeeId],
       e.LastName AS [Employee!1!LastName],
       NULL AS [EmployeeTerritories!2!TerritoryID]
FROM dbo.Employees e
UNION ALL
SELECT 2 AS Tag,
       1 AS Parent,
       et.EmployeeID AS [Employee!1!EmployeeId],
       NULL AS [Employee!1!LastName],
       et.TerritoryID AS [EmployeeTerritories!2!TerritoryID]
FROM dbo.EmployeeTerritories et
ORDER BY [Employee!1!EmployeeId],
         Parent
FOR XML EXPLICIT;</code></pre>
<p>When you run the above query, you will see a result similar to the one below.</p>
<p><img decoding="async" fetchpriority="high" class="alignnone wp-image-1036 size-full" src="https://mssqlquery.com/wp-content/uploads/2022/08/for-xml-explicit-in-sql-server-1.jpg" alt="For XML Explicit in SQL Server" width="700" height="454" srcset="https://mssqlquery.com/wp-content/uploads/2022/08/for-xml-explicit-in-sql-server-1.jpg 700w, https://mssqlquery.com/wp-content/uploads/2022/08/for-xml-explicit-in-sql-server-1-300x195.jpg 300w" sizes="(max-width: 700px) 100vw, 700px" /></p>
<p>Here you see the structures like Employee!1!EmployeeId. Numbers such as 1 and 2 in these structures you have seen correspond to the numbers opposite the Tag and Parent expressions. Also, in the expression Employee!1!EmployeeId, the expression EmployeeId must be written the same as the table expression in the database.</p>
<p>In the first select query, e.EmployeeID corresponds to 1 -&gt; Tag in AS [Employee!1!EmployeeId] structure.</p>
<p>In the second select query, et.EmployeeID corresponds to 1-&gt; Parent in AS [Employee!1!EmployeeId] structure. 2 corresponds to Tag.</p>
<p>If you do a little digging, you will understand the structure better.</p>
<p>Good luck to everyone in business and life.</p>
<div class='epvc-post-count'><span class='epvc-eye'></span>  <span class="epvc-count"> 104</span><span class='epvc-label'> Views</span></div><p>The post <a href="https://mssqlquery.com/for-xml-explicit-in-sql-server">For XML Explicit in SQL Server</a> first appeared on <a href="https://mssqlquery.com">MSSQL Query</a>.</p>]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
