What Are Comparison Operations in SQL Server

Q

What Are Comparison Operations in SQL Server Transact-SQL?

✍: FYIcenter.com

A

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.

 

Performing Comparison on Exact Numbers in SQL Server

CASE - Conditional Expressions in SQL Server

Boolean Values and Logical Operations in SQL Server Transact-SQL

⇑⇑ SQL Server Transact-SQL Tutorials

2017-01-29, 1745🔥, 0💬