Skip to content

Describe the UNKNOWN result of ALL and SOME or ANY - #10485

Open
Rudi Bruchez (rudi-bruchez) wants to merge 1 commit into
MicrosoftDocs:livefrom
rudi-bruchez:fix/all-any-unknown
Open

Rudi Bruchez (rudi-bruchez) wants to merge 1 commit into
MicrosoftDocs:livefrom
rudi-bruchez:fix/all-any-unknown

Conversation

@rudi-bruchez

Copy link
Copy Markdown
Contributor

What's wrong

The "Result value" section of the ALL page says: "Returns TRUE when the comparison specified is TRUE for all pairs ... Otherwise returns FALSE." The SOME | ANY page says the same: "otherwise, returns FALSE."

When a NULL value takes part in the comparison and decides the result, both return UNKNOWN: neither the condition nor its negation is true. 1 < ALL (2, NULL) isn't FALSE, since NOT (1 < ALL (2, NULL)) isn't TRUE either. A reader who relies on "otherwise FALSE" writes NOT (x < ALL (...)) and gets no rows.

Evidence

SQL Server 2025 CU10 (17.0.5035.5), Linux container, Developer edition. No database needed; default SET options of sqlcmd -I (ANSI_NULLS ON).

SET NOCOUNT ON;
SELECT t.expr,
  CASE WHEN t.r = 1 THEN 'TRUE' WHEN t.r = 0 THEN 'FALSE' ELSE 'UNKNOWN' END AS result
FROM (VALUES
 ('1 < ALL (2, 3)',     CASE WHEN 1 < ALL (SELECT v FROM (VALUES (2),(3)) t(v)) THEN 1 WHEN NOT (1 < ALL (SELECT v FROM (VALUES (2),(3)) t(v))) THEN 0 END),
 ('1 < ALL (2, NULL)',  CASE WHEN 1 < ALL (SELECT v FROM (VALUES (2),(NULL)) t(v)) THEN 1 WHEN NOT (1 < ALL (SELECT v FROM (VALUES (2),(NULL)) t(v))) THEN 0 END),
 ('3 < ALL (2, NULL)',  CASE WHEN 3 < ALL (SELECT v FROM (VALUES (2),(NULL)) t(v)) THEN 1 WHEN NOT (3 < ALL (SELECT v FROM (VALUES (2),(NULL)) t(v))) THEN 0 END),
 ('1 < ALL (empty)',    CASE WHEN 1 < ALL (SELECT v FROM (VALUES (2)) t(v) WHERE v > 5) THEN 1 WHEN NOT (1 < ALL (SELECT v FROM (VALUES (2)) t(v) WHERE v > 5)) THEN 0 END),
 ('NULL < ALL (2, 3)',  CASE WHEN CAST(NULL AS int) < ALL (SELECT v FROM (VALUES (2),(3)) t(v)) THEN 1 WHEN NOT (CAST(NULL AS int) < ALL (SELECT v FROM (VALUES (2),(3)) t(v))) THEN 0 END),
 ('3 > ANY (2, NULL)',  CASE WHEN 3 > ANY (SELECT v FROM (VALUES (2),(NULL)) t(v)) THEN 1 WHEN NOT (3 > ANY (SELECT v FROM (VALUES (2),(NULL)) t(v))) THEN 0 END),
 ('1 > ANY (2, NULL)',  CASE WHEN 1 > ANY (SELECT v FROM (VALUES (2),(NULL)) t(v)) THEN 1 WHEN NOT (1 > ANY (SELECT v FROM (VALUES (2),(NULL)) t(v))) THEN 0 END),
 ('1 > ANY (2, 3)',     CASE WHEN 1 > ANY (SELECT v FROM (VALUES (2),(3)) t(v)) THEN 1 WHEN NOT (1 > ANY (SELECT v FROM (VALUES (2),(3)) t(v))) THEN 0 END),
 ('1 > ANY (empty)',    CASE WHEN 1 > ANY (SELECT v FROM (VALUES (2)) t(v) WHERE v > 5) THEN 1 WHEN NOT (1 > ANY (SELECT v FROM (VALUES (2)) t(v) WHERE v > 5)) THEN 0 END)
) t(expr, r);
Expression Result
1 < ALL (2, 3) TRUE
1 < ALL (2, NULL) UNKNOWN
3 < ALL (2, NULL) FALSE
1 < ALL (empty) TRUE
NULL < ALL (2, 3) UNKNOWN
3 > ANY (2, NULL) TRUE
1 > ANY (2, NULL) UNKNOWN
1 > ANY (2, 3) FALSE
1 > ANY (empty) FALSE

Observed: UNKNOWN for 1 < ALL (2, NULL), NULL < ALL (2, 3) and 1 > ANY (2, NULL). Expected per the current text: FALSE.

Change

In both pages, keeps the TRUE condition, gives the FALSE condition, and says that the result is otherwise UNKNOWN. The text doesn't tie UNKNOWN to NULL values: 1 = ANY (1, NULL) is TRUE, and with ANSI_NULLS OFF comparisons with NULL can be TRUE or FALSE.

@prmerger-automator

Copy link
Copy Markdown
Contributor

Rudi Bruchez (@rudi-bruchez) : Thanks for your contribution! The author(s) and reviewer(s) have been notified to review your proposed change.

@learn-build-service-prod

Copy link
Copy Markdown
Contributor

Learn Build status updates of commit 9aebc6e:

✅ Validation status: passed

File Status Preview URL Details
docs/t-sql/language-elements/all-transact-sql.md ✅Succeeded
docs/t-sql/language-elements/some-any-transact-sql.md ✅Succeeded

For more details, please refer to the build report.

@prmerger-automator

Copy link
Copy Markdown
Contributor

Rudi Bruchez (@rudi-bruchez) : Thanks for your contribution! The author(s) and reviewer(s) have been notified to review your proposed change.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain, and the documentation changes clearly address the FALSE and UNKNOWN outcomes for ALL, SOME, and ANY.

No open issues 🎉

What changed in this PR

Updates the Transact-SQL reference pages for ALL and SOME | ANY to accurately document three-valued comparison results, including UNKNOWN outcomes.

Changes:

  • Clarifies when ALL returns FALSE and when the result is UNKNOWN.
  • Clarifies when SOME or ANY returns FALSE and when the result is UNKNOWN.
File Description
docs/​t-sql/​language-elements/​some-any-transact-sql.md Updates the SOME and ANY result-value description to document FALSE and UNKNOWN outcomes.
docs/​t-sql/​language-elements/​all-transact-sql.md Updates the ALL result-value description to document FALSE and UNKNOWN outcomes.

Review effort: Lite

@Court72

Copy link
Copy Markdown
Contributor

Umachandar Jayachandran (@uc-msft)

Can you review the proposed changes?

Important: When the changes are ready for publication, adding a #sign-off comment is the best way to signal that the PR is ready for the review team to merge.

#label:"aq-pr-triaged"
@MicrosoftDocs/public-repo-pr-review-team

@prmerger-automator prmerger-automator Bot added the aq-pr-triaged tracking label for the PR review team label Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants