«

»

Aug 14

Print this Post

SQL SERVER – Difference Between Union and Union All

SQL

UNION:

 


The UNION command is used to select related information from two tables, much like the JOIN command. However, when using the UNION command all selected columns need to be of the same data type. With UNION, only distinct values are selected.

 

UNION ALL:

 


The UNION ALL command is equal to the UNION command, except that UNION ALL selects all values.

 

The difference between Union and Union all is that Union all will not eliminate duplicate rows, instead it just pulls all rows from all tables fitting your query specifics and combines them into a table.

A UNION statement effectively does a SELECT DISTINCT on the results set. If you know that all the records returned are unique from your union, use UNION ALL instead, it gives faster results.

Permanent link to this article: http://www.zappmania.in/2013/08/14/sql-server-difference-between-union-and-union-all.htm

6 comments

1 ping

Skip to comment form

  1. Abhishek Jaiswal

    Nice work

  2. Abhishek Jaiswal

    looking forward to see more knowledgeable posts like this…

  3. whatsapp for pc

    Terrific article! That is the type of info that are meant to be shared
    around the web. Disgrace on Google for no longer positioning this put up
    higher! Come on over and consult with my site .
    Thanks =)

  4. candy crush cheats

    You’ve made some really good points there. I looked on the internet for more information about the issue and found
    most individuals will go along with your
    views on this web site.

  5. Malcolm

    Greetings from Florida! I’m bored at work so I decided to browse your
    website on my iphone during lunch break. I love the knowledge you present here and can’t wait to take a look when I get home.
    I’m amazed at how fast your blog loaded on my mobile ..
    I’m not even using WIFI, just 3G .. Anyhow,
    very good blog!

  6. Download Whatsapp for PC

    always i used to read smaller articles that as well clear their motive, and that is also happening with this article which I
    am reading here.

  1. URL

    … [Trackback]

    […] Informations on that Topic: zappmania.in/2013/08/14/sql-server-difference-between-union-and-union-all.html/ […]

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">