Home >> FAQs/Tutorials >> SQL Server FAQ

SQL Server FAQ - What Are Comparison Operations

By: FYIcenter.com

(Continued from previous topic...)

What Are Comparison Operations?

Comparison operations return Boolean values by comparing the relative positions of two operands. SQL server supports the following comparison operations:

  • = (Equal To): Returns Boolean true, if two operands are equal in value.
  • > (Greater Than): Returns Boolean true, if the left operand has a value greater than the right operand.
  • < (Less Than): Returns Boolean true, if the left operand has a value less than the right operand.
  • >= (Greater Than or Equal To): Returns Boolean true, if the left operand has a value greater than or equal to the right operand.
  • <= (Less Than or Equal To): Returns Boolean true, if the left operand has a value less than or equal to the right operand.
  • <> (Not Equal To): Returns Boolean true, if two operands are not equal in value.

There are several rules you need to remember about comparison operations:

  • Comparison operations can be performed on all data types: exact numbers, approximate numbers, character strings, and binary strings.
  • If two operands have different data types, the operand with a lower data type rank will be implicitly converted to the data type of the other operand.
  • Character string comparison will be performed based the rules defined in the associated collation.

(Continued on next topic...)

  1. What Is a Boolean Value?
  2. What Are Conditional Expressions?
  3. What Are Comparison Operations?
  4. How To Perform Comparison on Exact Numbers?
  5. How To Perform Comparison on Floating Point Numbers?
  6. How To Perform Comparison on Date and Time Values?
  7. How To Perform Comparison on Character Strings?
  8. What To Test Value Ranges with the BETWEEN Operator?
  9. What To Test Value Lists with the IN Operator?
  10. What To Perform Pattern Match with the LIKE Operator?
  11. How To Use Wildcard Characters in LIKE Operations?
  12. How To Test Subquery Results with the EXISTS Operator?
  13. How To Test Values Returned by a Subquery with the IN Operator?
  14. What Are Logical/Boolean Operations?

Related Articles:

More...


Other Tutorials/FAQs:

More...


Related Resources:

More...


Selected Jobs:

More...