UNION

External Article

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

Technical Article

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)

You rated this post out of 5. Change rating

2013-05-14 (first published: )

918 reads

Blogs

When It’s Still Viable

By

If a technology is still viable, don’t overlook it. Don’t get caught up chasing...

T-SQL Tuesday #179: The Detective’s Toolkit

By

It’s time for the monthly T-SQL Tuesday blog party. This month a longtime friend,...

Moving T-SQL Tuesday to Jekyll

By

I got a message a few months back that Microsoft was deprecating the MySQL...

Read the latest Blogs

Forums

case statement with and like operators

By Wren

Hello, I'm trying to remove results from this sql statement where the custid like...

update error. Subquery returned more than 1 value

By reza.asali

Hi friends. how can i fix that? ;with cte as (select distinct(e.Id ) from...

THE CSV PROBLEM

By fk.da

Hello everyone, First of all, thank you very much for this great community. I...

Visit the forum

Question of the Day

Data Migration Assistant Targets

In the current (2024) version of the Data Migration Assistant, which on-premises targets are available?

See possible answers