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

915 reads

Blogs

How Long Will It Take to Learn SQL? The Truth Might Surprise You

By

In today's data-driven world, SQL (Structured Query Language) is a blazing-hot skill. It's your...

Flying Halfway Around the World to Australia

By

I leave tonight for Australia. I was in London 3 days ago, so this...

Dealing with Change – Two Resources

By

As I look at the state of information technology today, I see one constant:...

Read the latest Blogs

Forums

Row-level security in SQL server

By dzukik0711

In this scenario, I seek assistance in implementing row-level permissions for a table named...

SSIS Web Service task SSL errors

By smithloo

I've tried different credentials, target server versions, etc. hitting our Primavera WSDL. Works great...

CDC Custom Alert

By Abdul122

Hi All,   I am writing an alert in a sql agent job, basically...

Visit the forum

Question of the Day

Initial Config of tempdb

What are the initial config sizes for the tempdb primary data files, secondary data files, and log files in SQL Server 2022?

See possible answers