«

»

Aug 14 2013

Abhishek Jaiswal

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.

Abhishek Jaiswal

About Abhishek Jaiswal

Abhishek Jaiswal has Contibuted 298 articles in this blog.

Hobby: reading/writing Knowledge based articles Technology/Skills : ASP.NET, SharePoint, C#, OOPs etc

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

4 comments

1 ping

Skip to comment form

  1. candy crush cheatsNo Gravatar

    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.

  2. whatsapp for pcNo Gravatar

    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 =)

  3. Abhishek Jaiswal
    Abhishek Jaiswal

    looking forward to see more knowledgeable posts like this…

  4. Abhishek Jaiswal
    Abhishek Jaiswal

    Nice work

  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=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

Powered By Indic IME