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
A shuttlecock resting exactly on a court's boundary line, two rackets lying still on either side of the net.

Three-Valued Logic: TRUE, FALSE and UNKNOWN in a WHERE Clause

May 15, 2013
Pinal Dave
SQL Tips and Tricks
SQL NULL, SQL Operator, SQL Server, SQL Server 2022, SQL Sub Query

Understand three-valued logic in WHERE and CHECK, avoid NULL-poisoned NOT IN, and use SQL Server 2022 null-safe comparisons.

Read More
A French fry cutter holds a potato against fixed blades with neatly cut pieces beneath it

Multi-Value Report Parameters in T-SQL Without Dynamic SQL

May 5, 2012
Pinal Dave
SQL Tips and Tricks
Reporting Services, SQL Error Messages, SQL String, SQL Sub Query

A report that sends 1, 2, 2, 3 does not need dynamic SQL. Here is how to split, validate and match the list safely.

Read More
Gouache painting of a database character beside a stopwatch

Convert Subquery to CTE: SQL in Sixty Seconds #001

February 8, 2012
Pinal Dave
SQL Video
CTE, SQL in Sixty Seconds, SQL Scripts, SQL Sub Query

You can convert subquery to CTE syntax by naming the inner query and using that name in the outer query. The first SQL in Sixty Seconds episode shows the change. My tests on SQL Server 2025 show the result stays the same, and that a CTE used twice reads the table twice.

Read More
Five crochet hooks in olive, blue, cream, blue and red stand in a row, with the red hook tallest

ANY and ALL: Comparing a Value to a Whole Subquery in T-SQL

August 22, 2011
Pinal Dave
SQL Tips and Tricks
SQL NULL, SQL Operator, SQL Sub Query, Temp Table

One missing price is enough to make ALL return nothing while ANY returns rows. Here is how to see it, and how to ask the question more safely.

Read More
Result of a LEFT JOIN from six plants to their order lines. Orchid, Bamboo and Mint show NULL in the LineID column, and the filter LineID IS NULL keeps only those three

Unmatched Records Query: Four Ways to Find Rows With No Match

August 5, 2011
Pinal Dave
SQL Tips and Tricks
SQL Joins, SQL NULL, SQL Scripts, SQL Sub Query

An unmatched records query finds the rows in one table that have no partner in another, such as plants that never sold. This post runs four versions on a small table: LEFT JOIN with a NULL test, NOT EXISTS, NOT IN and EXCEPT. It also shows the NULL trap that makes NOT IN return nothing.

Read More
Tangled fishing flies lie beside matching flies secured individually in a foam fly wallet

Large IN Lists: When a Temp Table Beats Thousands of Values

August 1, 2011
Pinal Dave
SQL Tips and Tricks
Primary Key, SQL Performance, SQL Sub Query, Temp Table

Pasting thousands of IDs into an IN list works, until it does not. See where the time goes and how to keep the answer the same with a temp table.

Read More
A muffin tin with one empty cup, while two muffins are squeezed together into the cup next to it.

Relational Division in T-SQL: Customers Who Bought Every Product

August 2, 2010
Pinal Dave
SQL Tips and Tricks
SQL Joins, SQL Scripts, SQL Server, SQL Sub Query

Solve relational division with counts and double NOT EXISTS, then handle duplicates, NULL values, empty requirements, and exact matching.

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

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