This month's discount Comprehensive Database Performance Health Check · Testimonials
SQLAuthority with Pinal Dave
Home
  • Consulting
    • Health Check
  • Free Videos
  • All Articles
    • AI
    • SQL Performance
    • SQL Tips and Tricks
    • Interview Questions and Answers
    • SQL Puzzle
    • SQL Video
    • SQLAuthority News
    • Personal
  • Books
  • Consulting
Remove Duplicate Rows Using UNION Operator.

SQL SERVER – Remove Duplicate Rows Using UNION Operator

September 19, 2018
Pinal Dave
SQL Tips and Tricks
SQL Scripts, SQL Server, SQL Union clause

Earlier I removed duplicate rows with ROW_NUMBER() and a CTE. This time I show a tricky alternative: removing duplicate rows with the traditional UNION operator.

Read More
SQL Server UNION vs UNION ALL Error.

SQL SERVER – Puzzle – Solution – Why Does UNION ALL Work but UNION Produces Error?

January 8, 2018
Pinal Dave
SQL Puzzle
SQL Scripts, SQL Server, SQL Union clause

Here is the answer to my puzzle: why does UNION ALL work but UNION produces an error with a TEXT column? It comes down to how UNION removes duplicates.

Read More
SQL Server UNION vs UNION ALL Error.

SQL SERVER – Puzzle – Why Does UNION ALL Work but UNION Produces Error?

January 4, 2018
Pinal Dave
SQL Puzzle
SQL Scripts, SQL Server, SQL Union clause

A puzzle with TEXT columns: UNION ALL works fine, but UNION produces error. Can you tell why? The hint is in how UNION removes duplicates.

Read More
SQL Server query with 2 tables.

SQL SERVER – Select Unique Data From a Column Exist in Two Different Table

September 26, 2017
Pinal Dave
SQL Puzzle
SQL Scripts, SQL Server, SQL Union clause

A reader wanted to Select Unique Data from a column in two tables, keeping only values found in just one of them. Here is the query that does it.

Read More
Interview Question of the Week #017 - Performance Comparison of Union vs Union All

Interview Question of the Week #017 – Performance Comparison of Union vs Union All

April 26, 2015
Pinal Dave
SQL Interview Questions and Answers
SQL Union clause

An interviewer asked which is faster, Union vs Union All. My answer: they do different jobs, so comparing them is like comparing apples and oranges.

Read More
Dialog box displaying error.

SQL SERVER – UNION With TEXT DataType Returns Error but and UNION ALL Works – Reasons

January 3, 2015
Pinal Dave
SQL Tips and Tricks
SQL Union clause

Why does UNION with TEXT datatype return an error while UNION ALL works? It comes down to how UNION removes duplicate rows. Here is the reason.

Read More
SQL union error dialog.

SQL SERVER – UNION and UNION ALL with TEXT DataType – Observation

December 30, 2014
Pinal Dave
SQL Tips and Tricks
SQL Union clause

UNION fails on a TEXT column with Msg 5335, yet UNION ALL with TEXT datatype works fine. Here is the code so you can try the difference yourself.

Read More
1 2 3 Next
  • Books
  • Testimonials
  • Privacy Policy

© 2006 – 2026 All rights reserved. pinal @ SQLAuthority.com