Comparison Operators – Part 2

I am going pick up writing my series of very short articles or tidbits on Transaction SQL Operators. An operator is a symbol specifying an action that is performed on one or more expressions.

I will continue examining the Comparison Operators today.

These comparison operators are known as the less than <, less than or equal to <=, equal to =, greater than >, and greater than or equal to >= symbols in inequality and equality mathematics.

I will be examining how a sample operator works with character, date/time, money and binary data types. Remember, character data types use the ASCII or UNICODE chart to determine if one character is greater than another. All other data types are based upon the value stored on disk or in memory.

The first example below shows the less than operator used with character data type.

The output of the first example is listed below.

The second example below shows the equal operator used with date/time data type. In this example, both variables are equal due to precision loss during rounding.

The output of the second example is listed below.

The third example below shows the greater than operator used with money data type.

The output of the third example is listed below.

The fourth example below shows the not equal to operator used with binary data type.

The output of the fourth example is listed below.

Next time, I will be chatting about how to use Compound Operators when writing Transaction SQL scripts.

Related posts

Leave a Comment