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
Two street lamps on a cobbled square at night whose pools of light overlap in one brighter patch

Splitting OR Conditions Into UNION ALL for Index Seeks

December 27, 2021
Pinal Dave
SQL Performance
Execution Plan, SQL Index, SQL Server, SQL Union clause

Test splitting OR conditions into disjoint UNION ALL branches, preserve NULL behavior and row identity, and compare actual index access.

Read More
Seven source tiles remain intact beside four distinct reliefs on a separate display board.

SQL SERVER – Remove Duplicate Rows Using UNION Operator

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

The UNION operator removes duplicates from a query result without deleting source rows. I use a small example to show that distinction.

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
Chestnut scoring knife making an opening beside scored and untouched chestnuts

OPENJSON WITH Clause: Converting JSON Properties to Typed Values

March 14, 2016
Pinal Dave
SQL Tips and Tricks
JSON, Output Clause, SQL Union clause

Without WITH, OPENJSON hands you text. With it, you pick the names and types and decide what happens when a property is missing.

Read More
Two apple collections show keeping every apple compared with selecting distinct ones

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

Compare UNION vs UNION ALL with duplicate examples, compatible types, actual plans, and the extra work required for distinct rows.

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

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