= (Equals) (Transact-SQL)

Compares the equality of two expressions (a comparison operator).

Topic link iconTransact-SQL Syntax Conventions


expression =expression


  • expression
    Is any valid expression. If the expressions are not of the same data type, the data type for one expression must be implicitly convertible to the data type of the other. The conversion is based on the rules of data type precedence.

Result Types



When you compare two NULL expressions, the result depends on the ANSI_NULLS setting:

  • If ANSI_NULLS is set to ON, the result is NULL, following the ANSI convention that a NULL (or unknown) value is not equal to another NULL or unknown value.

  • If ANSI_NULLS is set to OFF, the result of NULL compared to NULL is TRUE.

Comparing NULL to a non-NULL value always results in FALSE.