Relational-Operator Condition

A relational-operator condition is satisfied if the expressions on each side of the operator fulfill the relation that the operator specifies. The following statements use the greater than ( > ) and equal ( = ) relational operators:
SELECT order_num FROM orders
   WHERE order_date > '6/04/08';
SELECT fname, lname, company
   FROM customer
   WHERE city[1,3] = 'San';

Single quotation marks are required around 'San' because the substring is from a character column. See the Relational-Operator Condition.

Blank strings and empty strings in the WHERE clause

For LVARCHAR, NVARCHAR, or VARCHAR columns, queries with a WHERE clause specifying equality of the column value to an empty string (

WHERE varlength_col = ''

) return the same result set as an otherwise identical query in which the WHERE clause specifies equality to a string of blank (ASCII 32) characters.

For example, if varlength_col is of type VARCHAR, NVARCHAR, or LVARCHAR, the following WHERE clause examples are all functionally equivalent to a WHERE clause that specifies equality to an empty string:

   WHERE varlength_col = ' ' 
   WHERE varlength_col = '  '
   WHERE varlength_col = '   '

Thus, for the built-in variable-length character data types, the WHERE clause makes no distinction between an empty string and a string consisting entirely of one or more blank characters. (Note, however, that the query filter

   WHERE varlength_col IS NULL

is not equivalent to the previous WHERE clause examples, and returns a different result set if any varlength_col value is NULL.)