Export (0) Print
Expand All

BETWEEN

SQL Server 2000

Specifies a range to test.

Syntax
test_expression [ NOT ] BETWEEN begin_expression AND end_expression
Arguments
test_expression
Is the expression to test for in the range defined by begin_expression and end_expression. test_expression must be the same data type as both begin_expression and end_expression.
NOT
Specifies that the result of the predicate be negated.
begin_expression
Is any valid expression in Microsoft® SQL Server™ 2000 Windows® CE Edition (SQL Server CE). begin_expression must be the same data type as both test_expression and end_expression.
end_expression
Is any valid expression in SQL Server CE. end_expression must be the same data type as both test_expression and begin_expression.
AND
Acts as a placeholder indicating that test_expression should be within the range indicated by begin_expression and end_expression.
Result Types

bit

Result Value

BETWEEN returns TRUE if the value of test_expression is greater than or equal to the value of begin_expression and less than or equal to the value of 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.

Examples

The following example identifies the products in the Northwind database with 35 or fewer units in stock.

SELECT ProductID, ProductName FROM Products WHERE UnitsInStock BETWEEN '0' AND '35'

Show:
© 2014 Microsoft