UNION

UNION vs. UNION ALL in SQL Server

  • Article

Sometimes there is a need to combine data from multiple tables or views into one comprehensive dataset. This may be for like tables within the same database or maybe there is a need to combine like data across databases or even across servers. I have read about the UNION and UNION ALL commands, but how do these work and how do they differ?

2019-12-05

Union Forcing Distinct

  • Script

The use of union would seem to force a distinct in each of the select statements being unioned. The use multiple unions, with mixed union and union all clauses, seems to cause haphazard results.

1.67 (3)

2013-05-14 (first published: )

902 reads

Blogs

T-SQL Tuesday #121: Gifts received for this year

By

It’s T-SQL Tuesday time again! This edition is hosted by Malathi (blog|twitter) and the...

A gift. T-SQL Tuesday #121

By

My good friend Malathi Mahadevan (blog|twitter) is hosting T-SQL Tuesday this month and wants...

Distributing Jupyter Notebooks

By

If you’re working with the Microsoft Data Platform, you should be, at the least,...

Read the latest Blogs

Forums

List of INDEX with create and DROP script should not include any constrains P/F

By DBA.k

Hello Sir.. Please help me the script.. From entire database i want List of...

is there any better way to export SQL server data into csv file?

By 892717952

I have  questions of exporting SQL server data, the details as below, thanks! how...

Uninstall SQL without uninstalling SSRS

By Brandie Tarvin

We have a non-prod server that (long ago) we installed SQL Server on and...

Visit the forum

Ask SSC

SQL Server Q&A from the SQLServerCentral community

Get answers