<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='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'><id>tag:blogger.com,1999:blog-540108582205622091</id><updated>2024-09-09T19:14:19.861-07:00</updated><title type='text'>T-SQL Union all</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://t-sql-union-all.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/540108582205622091/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://t-sql-union-all.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06731273299234474960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>1</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-540108582205622091.post-6445336637925250905</id><published>2010-05-10T11:30:00.001-07:00</published><updated>2015-03-24T13:30:55.838-07:00</updated><title type='text'>SQL “Union” and “Union All”</title><content type='html'>&lt;link href=&quot;file:///D:%5CDOCUME%7E1%5CFCHOWD%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_filelist.xml&quot; rel=&quot;File-List&quot;&gt;&lt;/link&gt;&lt;link href=&quot;file:///D:%5CDOCUME%7E1%5CFCHOWD%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_themedata.thmx&quot; rel=&quot;themeData&quot;&gt;&lt;/link&gt;&lt;link href=&quot;file:///D:%5CDOCUME%7E1%5CFCHOWD%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_colorschememapping.xml&quot; rel=&quot;colorSchemeMapping&quot;&gt;&lt;/link&gt;&lt;style&gt;
&lt;!--
 /* Font Definitions */
 @font-face
 {font-family:&quot;Cambria Math&quot;;
 panose-1:2 4 5 3 5 4 6 3 2 4;
 mso-font-charset:1;
 mso-generic-font-family:roman;
 mso-font-format:other;
 mso-font-pitch:variable;
 mso-font-signature:0 0 0 0 0 0;}
@font-face
 {font-family:Calibri;
 panose-1:2 15 5 2 2 2 4 3 2 4;
 mso-font-charset:0;
 mso-generic-font-family:swiss;
 mso-font-pitch:variable;
 mso-font-signature:-1610611985 1073750139 0 0 159 0;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
 {mso-style-unhide:no;
 mso-style-qformat:yes;
 mso-style-parent:&quot;&quot;;
 margin-top:0in;
 margin-right:0in;
 margin-bottom:10.0pt;
 margin-left:0in;
 line-height:115%;
 mso-pagination:widow-orphan;
 font-size:11.0pt;
 font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;
 mso-ascii-font-family:Calibri;
 mso-ascii-theme-font:minor-latin;
 mso-fareast-font-family:Calibri;
 mso-fareast-theme-font:minor-latin;
 mso-hansi-font-family:Calibri;
 mso-hansi-theme-font:minor-latin;
 mso-bidi-font-family:&quot;Times New Roman&quot;;
 mso-bidi-theme-font:minor-bidi;}
.MsoChpDefault
 {mso-style-type:export-only;
 mso-default-props:yes;
 mso-ascii-font-family:Calibri;
 mso-ascii-theme-font:minor-latin;
 mso-fareast-font-family:Calibri;
 mso-fareast-theme-font:minor-latin;
 mso-hansi-font-family:Calibri;
 mso-hansi-theme-font:minor-latin;
 mso-bidi-font-family:&quot;Times New Roman&quot;;
 mso-bidi-theme-font:minor-bidi;}
.MsoPapDefault
 {mso-style-type:export-only;
 margin-bottom:10.0pt;
 line-height:115%;}
@page Section1
 {size:8.5in 11.0in;
 margin:1.0in 1.0in 1.0in 1.0in;
 mso-header-margin:.5in;
 mso-footer-margin:.5in;
 mso-paper-source:0;}
div.Section1
 {page:Section1;}
&lt;/style&gt;

--&amp;gt;  &lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background-color: white; color: blue;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;SQL “Union” and “Union All”&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background-color: white; color: blue;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
SQL union combines two or more tables. Let’s say, I have two tables &lt;span style=&quot;background: none repeat scroll 0% 0% silver; color: teal; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; line-height: 115%;&quot;&gt;Persons_BD&lt;/span&gt;&lt;span style=&quot;color: teal; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; line-height: 115%;&quot;&gt; and &lt;span style=&quot;background: none repeat scroll 0% 0% silver;&quot;&gt;Persons_&lt;/span&gt;US&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
They both have similar column names that I will try to combine with Union query.&amp;nbsp; Persons_US has data like: &lt;/div&gt;
&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;MsoTableGrid&quot; style=&quot;border-collapse: collapse; border: medium none;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;   &lt;td style=&quot;border: 1pt solid black; padding: 0in 5.4pt; width: 95.75pt;&quot; valign=&quot;top&quot; width=&quot;128&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;
P_Id&lt;/div&gt;
&lt;/td&gt;   &lt;td style=&quot;border-color: black black black -moz-use-text-color; border-style: solid solid solid none; border-width: 1pt 1pt 1pt medium; padding: 0in 5.4pt; width: 95.75pt;&quot; valign=&quot;top&quot; width=&quot;128&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;
LastName&lt;/div&gt;
&lt;/td&gt;   &lt;td style=&quot;border-color: black black black -moz-use-text-color; border-style: solid solid solid none; border-width: 1pt 1pt 1pt medium; padding: 0in 5.4pt; width: 95.75pt;&quot; valign=&quot;top&quot; width=&quot;128&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;
FirstName&lt;/div&gt;
&lt;/td&gt;   &lt;td style=&quot;border-color: black black black -moz-use-text-color; border-style: solid solid solid none; border-width: 1pt 1pt 1pt medium; padding: 0in 5.4pt; width: 95.75pt;&quot; valign=&quot;top&quot; width=&quot;128&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;
Address&lt;/div&gt;
&lt;/td&gt;   &lt;td style=&quot;border-color: black black black -moz-use-text-color; border-style: solid solid solid none; border-width: 1pt 1pt 1pt medium; padding: 0in 5.4pt; width: 95.8pt;&quot; valign=&quot;top&quot; width=&quot;128&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;
City&lt;/div&gt;
&lt;/td&gt;  &lt;/tr&gt;
&lt;tr&gt;   &lt;td style=&quot;border-color: -moz-use-text-color black black; border-style: none solid solid; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 95.75pt;&quot; valign=&quot;top&quot; width=&quot;128&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;
1&lt;/div&gt;
&lt;/td&gt;   &lt;td style=&quot;border-color: -moz-use-text-color black black -moz-use-text-color; border-style: none solid solid none; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 95.75pt;&quot; valign=&quot;top&quot; width=&quot;128&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;
Chowdhury&lt;/div&gt;
&lt;/td&gt;   &lt;td style=&quot;border-color: -moz-use-text-color black black -moz-use-text-color; border-style: none solid solid none; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 95.75pt;&quot; valign=&quot;top&quot; width=&quot;128&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;
Pavel&lt;/div&gt;
&lt;/td&gt;   &lt;td style=&quot;border-color: -moz-use-text-color black black -moz-use-text-color; border-style: none solid solid none; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 95.75pt;&quot; valign=&quot;top&quot; width=&quot;128&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;
3326 82ns Street&lt;/div&gt;
&lt;/td&gt;   &lt;td style=&quot;border-color: -moz-use-text-color black black -moz-use-text-color; border-style: none solid solid none; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 95.8pt;&quot; valign=&quot;top&quot; width=&quot;128&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;
Sandnes&lt;/div&gt;
&lt;/td&gt;  &lt;/tr&gt;
&lt;tr&gt;   &lt;td style=&quot;border-color: -moz-use-text-color black black; border-style: none solid solid; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 95.75pt;&quot; valign=&quot;top&quot; width=&quot;128&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;
2&lt;/div&gt;
&lt;/td&gt;   &lt;td style=&quot;border-color: -moz-use-text-color black black -moz-use-text-color; border-style: none solid solid none; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 95.75pt;&quot; valign=&quot;top&quot; width=&quot;128&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;
Chowdhury&lt;/div&gt;
&lt;/td&gt;   &lt;td style=&quot;border-color: -moz-use-text-color black black -moz-use-text-color; border-style: none solid solid none; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 95.75pt;&quot; valign=&quot;top&quot; width=&quot;128&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;
Nitol&lt;/div&gt;
&lt;/td&gt;   &lt;td style=&quot;border-color: -moz-use-text-color black black -moz-use-text-color; border-style: none solid solid none; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 95.75pt;&quot; valign=&quot;top&quot; width=&quot;128&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;
Dhaka Street&lt;/div&gt;
&lt;/td&gt;   &lt;td style=&quot;border-color: -moz-use-text-color black black -moz-use-text-color; border-style: none solid solid none; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 95.8pt;&quot; valign=&quot;top&quot; width=&quot;128&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;
Dhaka&lt;/div&gt;
&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
And Person_BD have data like &lt;/div&gt;
&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;MsoTableGrid&quot; style=&quot;border-collapse: collapse; border: medium none;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;   &lt;td style=&quot;border: 1pt solid black; padding: 0in 5.4pt; width: 95.75pt;&quot; valign=&quot;top&quot; width=&quot;128&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;
P_Id&lt;/div&gt;
&lt;/td&gt;   &lt;td style=&quot;border-color: black black black -moz-use-text-color; border-style: solid solid solid none; border-width: 1pt 1pt 1pt medium; padding: 0in 5.4pt; width: 95.75pt;&quot; valign=&quot;top&quot; width=&quot;128&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;
LastName&lt;/div&gt;
&lt;/td&gt;   &lt;td style=&quot;border-color: black black black -moz-use-text-color; border-style: solid solid solid none; border-width: 1pt 1pt 1pt medium; padding: 0in 5.4pt; width: 95.75pt;&quot; valign=&quot;top&quot; width=&quot;128&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;
FirstName&lt;/div&gt;
&lt;/td&gt;   &lt;td style=&quot;border-color: black black black -moz-use-text-color; border-style: solid solid solid none; border-width: 1pt 1pt 1pt medium; padding: 0in 5.4pt; width: 95.75pt;&quot; valign=&quot;top&quot; width=&quot;128&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;
Address&lt;/div&gt;
&lt;/td&gt;   &lt;td style=&quot;border-color: black black black -moz-use-text-color; border-style: solid solid solid none; border-width: 1pt 1pt 1pt medium; padding: 0in 5.4pt; width: 95.8pt;&quot; valign=&quot;top&quot; width=&quot;128&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;
City&lt;/div&gt;
&lt;/td&gt;  &lt;/tr&gt;
&lt;tr&gt;   &lt;td style=&quot;border-color: -moz-use-text-color black black; border-style: none solid solid; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 95.75pt;&quot; valign=&quot;top&quot; width=&quot;128&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;
2&lt;/div&gt;
&lt;/td&gt;   &lt;td style=&quot;border-color: -moz-use-text-color black black -moz-use-text-color; border-style: none solid solid none; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 95.75pt;&quot; valign=&quot;top&quot; width=&quot;128&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;
Chowdhury&lt;/div&gt;
&lt;/td&gt;   &lt;td style=&quot;border-color: -moz-use-text-color black black -moz-use-text-color; border-style: none solid solid none; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 95.75pt;&quot; valign=&quot;top&quot; width=&quot;128&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;
Nitol&lt;/div&gt;
&lt;/td&gt;   &lt;td style=&quot;border-color: -moz-use-text-color black black -moz-use-text-color; border-style: none solid solid none; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 95.75pt;&quot; valign=&quot;top&quot; width=&quot;128&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;
Dhaka Street&lt;/div&gt;
&lt;/td&gt;   &lt;td style=&quot;border-color: -moz-use-text-color black black -moz-use-text-color; border-style: none solid solid none; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 95.8pt;&quot; valign=&quot;top&quot; width=&quot;128&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;
Dhaka&lt;/div&gt;
&lt;/td&gt;  &lt;/tr&gt;
&lt;tr&gt;   &lt;td style=&quot;border-color: -moz-use-text-color black black; border-style: none solid solid; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 95.75pt;&quot; valign=&quot;top&quot; width=&quot;128&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;
2&lt;/div&gt;
&lt;/td&gt;   &lt;td style=&quot;border-color: -moz-use-text-color black black -moz-use-text-color; border-style: none solid solid none; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 95.75pt;&quot; valign=&quot;top&quot; width=&quot;128&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;
Chowdhury&lt;/div&gt;
&lt;/td&gt;   &lt;td style=&quot;border-color: -moz-use-text-color black black -moz-use-text-color; border-style: none solid solid none; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 95.75pt;&quot; valign=&quot;top&quot; width=&quot;128&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;
Pavel&lt;/div&gt;
&lt;/td&gt;   &lt;td style=&quot;border-color: -moz-use-text-color black black -moz-use-text-color; border-style: none solid solid none; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 95.75pt;&quot; valign=&quot;top&quot; width=&quot;128&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;
Dhaka Street&lt;/div&gt;
&lt;/td&gt;   &lt;td style=&quot;border-color: -moz-use-text-color black black -moz-use-text-color; border-style: none solid solid none; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 95.8pt;&quot; valign=&quot;top&quot; width=&quot;128&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;
Dhaka&lt;/div&gt;
&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Now, if I run this query &lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;background: none repeat scroll 0% 0% silver; color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;background: none repeat scroll 0% 0% silver; color: teal; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt; FIRSTNAME &lt;/span&gt;&lt;span style=&quot;background: none repeat scroll 0% 0% silver; color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;background: none repeat scroll 0% 0% silver; color: red; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&#39;&amp;nbsp; &#39;&lt;/span&gt;&lt;span style=&quot;background: none repeat scroll 0% 0% silver; color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;background: none repeat scroll 0% 0% silver; color: teal; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt; LASTNAME &lt;/span&gt;&lt;span style=&quot;background: none repeat scroll 0% 0% silver; color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;background: none repeat scroll 0% 0% silver; color: teal; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background: none repeat scroll 0% 0% silver; color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;NAME&lt;/span&gt;&lt;span style=&quot;background: none repeat scroll 0% 0% silver; color: teal; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background: none repeat scroll 0% 0% silver; color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;background: none repeat scroll 0% 0% silver; color: teal; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt; DBO&lt;/span&gt;&lt;span style=&quot;background: none repeat scroll 0% 0% silver; color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;background: none repeat scroll 0% 0% silver; color: teal; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;PERSONS&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;background: none repeat scroll 0% 0% silver; color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;UNION&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;background: none repeat scroll 0% 0% silver; color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; line-height: 115%;&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;background: none repeat scroll 0% 0% silver; color: teal; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; line-height: 115%;&quot;&gt; FIRSTNAME &lt;/span&gt;&lt;span style=&quot;background: none repeat scroll 0% 0% silver; color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; line-height: 115%;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;background: none repeat scroll 0% 0% silver; color: red; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; line-height: 115%;&quot;&gt;&#39;&amp;nbsp; &#39;&lt;/span&gt;&lt;span style=&quot;background: none repeat scroll 0% 0% silver; color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; line-height: 115%;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;background: none repeat scroll 0% 0% silver; color: teal; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; line-height: 115%;&quot;&gt; LASTNAME &lt;/span&gt;&lt;span style=&quot;background: none repeat scroll 0% 0% silver; color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; line-height: 115%;&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;background: none repeat scroll 0% 0% silver; color: teal; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; line-height: 115%;&quot;&gt; DBO&lt;/span&gt;&lt;span style=&quot;background: none repeat scroll 0% 0% silver; color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; line-height: 115%;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;background: none repeat scroll 0% 0% silver; color: teal; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; line-height: 115%;&quot;&gt;PERSONS1&lt;/span&gt;&lt;span style=&quot;color: teal; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; line-height: 115%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: teal; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; line-height: 115%;&quot;&gt;The result set will be &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;MsoTableGrid&quot; style=&quot;border-collapse: collapse; border: medium none;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;   &lt;td style=&quot;border: 1pt solid black; padding: 0in 5.4pt; width: 108.9pt;&quot; valign=&quot;top&quot; width=&quot;145&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;
NAME&lt;/div&gt;
&lt;/td&gt;  &lt;/tr&gt;
&lt;tr&gt;   &lt;td style=&quot;border-color: -moz-use-text-color black black; border-style: none solid solid; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 108.9pt;&quot; valign=&quot;top&quot; width=&quot;145&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;
Nitol&amp;nbsp; Chowdhury&lt;/div&gt;
&lt;/td&gt;  &lt;/tr&gt;
&lt;tr&gt;   &lt;td style=&quot;border-color: -moz-use-text-color black black; border-style: none solid solid; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 108.9pt;&quot; valign=&quot;top&quot; width=&quot;145&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;
Pavel&amp;nbsp; Chowdhury&lt;/div&gt;
&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
However, if I use UNION ALL look the result set is different&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;background: none repeat scroll 0% 0% silver; color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;background: none repeat scroll 0% 0% silver; color: teal; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt; FIRSTNAME &lt;/span&gt;&lt;span style=&quot;background: none repeat scroll 0% 0% silver; color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;background: none repeat scroll 0% 0% silver; color: red; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&#39;&amp;nbsp; &#39;&lt;/span&gt;&lt;span style=&quot;background: none repeat scroll 0% 0% silver; color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;background: none repeat scroll 0% 0% silver; color: teal; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt; LASTNAME &lt;/span&gt;&lt;span style=&quot;background: none repeat scroll 0% 0% silver; color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;background: none repeat scroll 0% 0% silver; color: teal; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background: none repeat scroll 0% 0% silver; color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;NAME&lt;/span&gt;&lt;span style=&quot;background: none repeat scroll 0% 0% silver; color: teal; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background: none repeat scroll 0% 0% silver; color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;background: none repeat scroll 0% 0% silver; color: teal; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt; DBO&lt;/span&gt;&lt;span style=&quot;background: none repeat scroll 0% 0% silver; color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;background: none repeat scroll 0% 0% silver; color: teal; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;PERSONS&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;background: none repeat scroll 0% 0% silver; color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;UNION ALL&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;background: none repeat scroll 0% 0% silver; color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;background: none repeat scroll 0% 0% silver; color: teal; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt; FIRSTNAME &lt;/span&gt;&lt;span style=&quot;background: none repeat scroll 0% 0% silver; color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;background: none repeat scroll 0% 0% silver; color: red; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&#39;&amp;nbsp; &#39;&lt;/span&gt;&lt;span style=&quot;background: none repeat scroll 0% 0% silver; color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;background: none repeat scroll 0% 0% silver; color: teal; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt; LASTNAME &lt;/span&gt;&lt;span style=&quot;background: none repeat scroll 0% 0% silver; color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;background: none repeat scroll 0% 0% silver; color: teal; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt; DBO&lt;/span&gt;&lt;span style=&quot;background: none repeat scroll 0% 0% silver; color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;background: none repeat scroll 0% 0% silver; color: teal; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;PERSONS1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;MsoTableGrid&quot; style=&quot;border-collapse: collapse; border: medium none;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;   &lt;td style=&quot;border: 1pt solid black; padding: 0in 5.4pt; width: 108.9pt;&quot; valign=&quot;top&quot; width=&quot;145&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;
NAME&lt;/div&gt;
&lt;/td&gt;  &lt;/tr&gt;
&lt;tr&gt;   &lt;td style=&quot;border-color: -moz-use-text-color black black; border-style: none solid solid; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 108.9pt;&quot; valign=&quot;top&quot; width=&quot;145&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;
Pavel&amp;nbsp; Chowdhury&lt;/div&gt;
&lt;/td&gt;  &lt;/tr&gt;
&lt;tr&gt;   &lt;td style=&quot;border-color: -moz-use-text-color black black; border-style: none solid solid; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 108.9pt;&quot; valign=&quot;top&quot; width=&quot;145&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;
Nitol&amp;nbsp; Chowdhury&lt;/div&gt;
&lt;/td&gt;  &lt;/tr&gt;
&lt;tr&gt;   &lt;td style=&quot;border-color: -moz-use-text-color black black; border-style: none solid solid; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 108.9pt;&quot; valign=&quot;top&quot; width=&quot;145&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;
Nitol&amp;nbsp; Chowdhury&lt;/div&gt;
&lt;/td&gt;  &lt;/tr&gt;
&lt;tr&gt;   &lt;td style=&quot;border-color: -moz-use-text-color black black; border-style: none solid solid; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 108.9pt;&quot; valign=&quot;top&quot; width=&quot;145&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;
Pavel&amp;nbsp; Chowdhury&lt;/div&gt;
&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
This is because UNION compare the tables and bring the result only the information that are common. &lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://t-sql-union-all.blogspot.com/feeds/6445336637925250905/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://t-sql-union-all.blogspot.com/2010/05/sql-union-and-union-all.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/540108582205622091/posts/default/6445336637925250905'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/540108582205622091/posts/default/6445336637925250905'/><link rel='alternate' type='text/html' href='http://t-sql-union-all.blogspot.com/2010/05/sql-union-and-union-all.html' title='SQL “Union” and “Union All”'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06731273299234474960</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>