<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: SQL SERVER &#8211; Introduction and Example of UNION and UNION ALL</title>
	<atom:link href="http://blog.sqlauthority.com/2008/10/15/sql-server-introduction-and-example-of-union-and-union-all/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2008/10/15/sql-server-introduction-and-example-of-union-and-union-all/</link>
	<description>Notes of a SQL Server MVP and Database Administrator</description>
	<lastBuildDate>Sat, 21 Nov 2009 05:54:09 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Aparna</title>
		<link>http://blog.sqlauthority.com/2008/10/15/sql-server-introduction-and-example-of-union-and-union-all/#comment-52639</link>
		<dc:creator>Aparna</dc:creator>
		<pubDate>Tue, 02 Jun 2009 07:58:46 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1364#comment-52639</guid>
		<description>I was short of time with lots of work in hand so did not really look at the execution plan. I will post my findings in this forum. Thanks Imran for your suggestion. wondering if anyone had similar issues.

FYI Table 1 is not distint by itself and Table 2 is not distinct by itself but there are dateid&#039;s in Table1 and Table2 that makes their union distinct

TABLE1
DATEID       INVESTOR
20090530  1
20090530  2
20090530 1

TABLE 2

DATEID       INVESTOR
20090630  1
20090630  2
20090630 1

Any one has thoughts until I look at the execution plan</description>
		<content:encoded><![CDATA[<p>I was short of time with lots of work in hand so did not really look at the execution plan. I will post my findings in this forum. Thanks Imran for your suggestion. wondering if anyone had similar issues.</p>
<p>FYI Table 1 is not distint by itself and Table 2 is not distinct by itself but there are dateid&#8217;s in Table1 and Table2 that makes their union distinct</p>
<p>TABLE1<br />
DATEID       INVESTOR<br />
20090530  1<br />
20090530  2<br />
20090530 1</p>
<p>TABLE 2</p>
<p>DATEID       INVESTOR<br />
20090630  1<br />
20090630  2<br />
20090630 1</p>
<p>Any one has thoughts until I look at the execution plan</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Imran Mohammed</title>
		<link>http://blog.sqlauthority.com/2008/10/15/sql-server-introduction-and-example-of-union-and-union-all/#comment-52631</link>
		<dc:creator>Imran Mohammed</dc:creator>
		<pubDate>Tue, 02 Jun 2009 04:59:59 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1364#comment-52631</guid>
		<description>@Aparna, 

Why don&#039;t you look at Execution plan. Look at cost of each step and each query. You will get an answer.

Also, please post your observation.

~ IM.</description>
		<content:encoded><![CDATA[<p>@Aparna, </p>
<p>Why don&#8217;t you look at Execution plan. Look at cost of each step and each query. You will get an answer.</p>
<p>Also, please post your observation.</p>
<p>~ IM.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aparna</title>
		<link>http://blog.sqlauthority.com/2008/10/15/sql-server-introduction-and-example-of-union-and-union-all/#comment-52626</link>
		<dc:creator>Aparna</dc:creator>
		<pubDate>Tue, 02 Jun 2009 02:28:42 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1364#comment-52626</guid>
		<description>I was looking at performance gaining and a friend of mine doing a peer review of my code suggested that we use union all instead of union, I was not sure how I will gain performance and while researching came across your article. 

I do need a distinct list of records and therefore used union
but she has an opinion that I do a union all and then group by the columns individually before applying union all. 

Which is best?
get the distinct list of table 1 (by using group by clause) and distinct list of table2 and then do union all 

or select list from table 1 and select list from table 2 and do union there by eliminating duplicates in individual tables</description>
		<content:encoded><![CDATA[<p>I was looking at performance gaining and a friend of mine doing a peer review of my code suggested that we use union all instead of union, I was not sure how I will gain performance and while researching came across your article. </p>
<p>I do need a distinct list of records and therefore used union<br />
but she has an opinion that I do a union all and then group by the columns individually before applying union all. </p>
<p>Which is best?<br />
get the distinct list of table 1 (by using group by clause) and distinct list of table2 and then do union all </p>
<p>or select list from table 1 and select list from table 2 and do union there by eliminating duplicates in individual tables</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ria</title>
		<link>http://blog.sqlauthority.com/2008/10/15/sql-server-introduction-and-example-of-union-and-union-all/#comment-52534</link>
		<dc:creator>Ria</dc:creator>
		<pubDate>Fri, 29 May 2009 11:11:55 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1364#comment-52534</guid>
		<description>Is it possible to use &#039;union all&#039; in hibernate, Since I am using Java and Hibernate for my application, I need to convert the query using &#039;union all&#039; to hibernate.Please Help me to solve this issue.</description>
		<content:encoded><![CDATA[<p>Is it possible to use &#8216;union all&#8217; in hibernate, Since I am using Java and Hibernate for my application, I need to convert the query using &#8216;union all&#8217; to hibernate.Please Help me to solve this issue.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: chris</title>
		<link>http://blog.sqlauthority.com/2008/10/15/sql-server-introduction-and-example-of-union-and-union-all/#comment-50261</link>
		<dc:creator>chris</dc:creator>
		<pubDate>Tue, 31 Mar 2009 06:00:46 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1364#comment-50261</guid>
		<description>sorry for the dumb question, i should have included tcol3 in my inner query...</description>
		<content:encoded><![CDATA[<p>sorry for the dumb question, i should have included tcol3 in my inner query&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: chris</title>
		<link>http://blog.sqlauthority.com/2008/10/15/sql-server-introduction-and-example-of-union-and-union-all/#comment-50260</link>
		<dc:creator>chris</dc:creator>
		<pubDate>Tue, 31 Mar 2009 05:55:17 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1364#comment-50260</guid>
		<description>is ther a way to use a union all statement and then issue a where at the end to filter the entire query?

example:

table 1 
tcol1 tcol2 tcol3
1      1       1
2      2       1

table 2
tcol1 tcol2 tcol3
3      3       1
4      4       2

SELECT tcol1,tcol2 FROM (
SELECT tcol1,tcol2
UNION ALL
SELECT tcol1,tcol2
) AS temptable
WHERE tcol3=&#039;1&#039;  &lt;--- 

thanks</description>
		<content:encoded><![CDATA[<p>is ther a way to use a union all statement and then issue a where at the end to filter the entire query?</p>
<p>example:</p>
<p>table 1<br />
tcol1 tcol2 tcol3<br />
1      1       1<br />
2      2       1</p>
<p>table 2<br />
tcol1 tcol2 tcol3<br />
3      3       1<br />
4      4       2</p>
<p>SELECT tcol1,tcol2 FROM (<br />
SELECT tcol1,tcol2<br />
UNION ALL<br />
SELECT tcol1,tcol2<br />
) AS temptable<br />
WHERE tcol3=&#8217;1&#8242;  &lt;&#8212; </p>
<p>thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Siuli Basu</title>
		<link>http://blog.sqlauthority.com/2008/10/15/sql-server-introduction-and-example-of-union-and-union-all/#comment-45222</link>
		<dc:creator>Siuli Basu</dc:creator>
		<pubDate>Wed, 31 Dec 2008 08:43:40 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1364#comment-45222</guid>
		<description>I want to know the difference between UNION and INSERT INTO</description>
		<content:encoded><![CDATA[<p>I want to know the difference between UNION and INSERT INTO</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vani K Patil</title>
		<link>http://blog.sqlauthority.com/2008/10/15/sql-server-introduction-and-example-of-union-and-union-all/#comment-44151</link>
		<dc:creator>Vani K Patil</dc:creator>
		<pubDate>Tue, 11 Nov 2008 09:34:05 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1364#comment-44151</guid>
		<description>First time i am going through this site.It&#039;s simply the best.
U have all the details without redundant details. Thanks tons for this.</description>
		<content:encoded><![CDATA[<p>First time i am going through this site.It&#8217;s simply the best.<br />
U have all the details without redundant details. Thanks tons for this.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joggee</title>
		<link>http://blog.sqlauthority.com/2008/10/15/sql-server-introduction-and-example-of-union-and-union-all/#comment-43703</link>
		<dc:creator>Joggee</dc:creator>
		<pubDate>Wed, 15 Oct 2008 03:32:05 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1364#comment-43703</guid>
		<description>Its a hobby to read your blog&#039;s article on daily basis to refresh my knowledge.

Some tricky part which mostly ignore, Catch it from your articles.

Keep up the good work.

God Bless you

Joggee.</description>
		<content:encoded><![CDATA[<p>Its a hobby to read your blog&#8217;s article on daily basis to refresh my knowledge.</p>
<p>Some tricky part which mostly ignore, Catch it from your articles.</p>
<p>Keep up the good work.</p>
<p>God Bless you</p>
<p>Joggee.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Imran Mohammed</title>
		<link>http://blog.sqlauthority.com/2008/10/15/sql-server-introduction-and-example-of-union-and-union-all/#comment-43701</link>
		<dc:creator>Imran Mohammed</dc:creator>
		<pubDate>Wed, 15 Oct 2008 02:04:23 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1364#comment-43701</guid>
		<description>Hello, 

I wish I had read this article one day before. 

Yesterday when I was working on one production issue, I saw a strange case, in which we create two temporary table on the fly, and then we do a select statement with a union. Every time we use to get an error... You wont believe we spent 2-3 hours on it. At last we saw the temporary tables that were created with select * into command was creating different datatype, one with int and another with char, and union was not able to perform its action and our process was failing. I learnt a good lesson, it was worth it :)

Thanks,
Imran.</description>
		<content:encoded><![CDATA[<p>Hello, </p>
<p>I wish I had read this article one day before. </p>
<p>Yesterday when I was working on one production issue, I saw a strange case, in which we create two temporary table on the fly, and then we do a select statement with a union. Every time we use to get an error&#8230; You wont believe we spent 2-3 hours on it. At last we saw the temporary tables that were created with select * into command was creating different datatype, one with int and another with char, and union was not able to perform its action and our process was failing. I learnt a good lesson, it was worth it :)</p>
<p>Thanks,<br />
Imran.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
