Are != identical in terms of their performance in SQL server?

218    Asked by ClareMatthews in SQL Server , Asked on Mar 14, 2023
<> is ... the same as !=.

But then a commenter pipes up and says:

It's true that they are, functionally, the same. However, how the SQL optimizer uses them is very different. =/!= are simply evaluated as true/false whereas <> means the engine has to look and see if the value is greater than or less than, meaning more performance overhead. Just something to consider when writing queries that may be expensive.


I am confident this is false, but in order to address potential sceptics, I wonder if anyone can provide an authoritative or canonical source to prove that these operators are not just functionally the same, but identical in all aspects?

Answered by Dipika Agarwal

That is incorrect, Books Online (BOL) says they are functionally the same:


!= (Not Equal To) (Transact-SQL)
And if you look at an execution plan where != is used, under Predicate, it changes != to <>.

Your Answer

Interviews

Parent Categories