From ea365994a9bc5505490b1d72a228a42e4526ef31 Mon Sep 17 00:00:00 2001 From: asos-martinsmith <101659886+asos-martinsmith@users.noreply.github.com> Date: Sat, 25 Jan 2025 12:08:14 +0000 Subject: [PATCH] Update between-transact-sql.md The statement that if any part is `NULL` the overall expression evaluates to `UNKNOWN` is not correct. Counter example ``` SELECT 1 WHERE NOT 2 BETWEEN NULL AND 1 ``` Because that is equivalent to ``` 2 >= NULL AND 2 <= 1 ``` or ``` UNKNOWN AND FALSE ``` Which is `FALSE` --- docs/t-sql/language-elements/between-transact-sql.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/t-sql/language-elements/between-transact-sql.md b/docs/t-sql/language-elements/between-transact-sql.md index 735b02c78bf..2659570751f 100644 --- a/docs/t-sql/language-elements/between-transact-sql.md +++ b/docs/t-sql/language-elements/between-transact-sql.md @@ -61,7 +61,8 @@ test_expression [ NOT ] BETWEEN begin_expression AND end_expression NOT BETWEEN returns **TRUE** if the value of *test_expression* is less than the value of *begin_expression* or greater than the value of *end_expression*. ## Remarks - To specify an exclusive range, use the greater than (>) and less than operators (<). If any input to the BETWEEN or NOT BETWEEN predicate is NULL, the result is UNKNOWN. + To specify an exclusive range, use the greater than (>) and less than operators (<). If any input to the BETWEEN or NOT BETWEEN predicate is NULL, the result depends on the results of the constituent parts. +`test_expression >= begin_expression AND test_expression <= end_expression`. If either part is FALSE then the overall BETWEEN expression evaluates to FALSE. Otherwise the expression will evaluate to UNKNOWN. ## Examples