i did the following query , with execution plan. i comment every query with the result of plan:
using "="
--index seek
--relative to batch 11%
--subtree cost 0.003
--estimated IO cost 0.003
--estimated rows: 1
select * from Production.Product
where ProductID =5
-----------------------------------------------------------------------
using "<>"
--index seek
--relative to batch 44%
--estimated IO cost 0.012
--subtree cost 0.012
--estimated rows: 503
select * from Production.Product
where ProductID <>5
-----------------------------------------------------------------------------
using < value1 or > value2
--index seek
--relative to batch 44%
--estimated IO cost 0.012
--subtree cost 0.012
--estimated rows: 503
select * from Production.Product
where ProductID <4
or ProductID >6
conclusion:
- all cases activate index seek , so no performance lost
-you find "<>" equivalant to "< value or > valu" in performance.
- using "<>" operator has no disadvantage , the only effect is the expected number of rows and consequently estimated IO cost
- it seems "=" better , but realyy it is not , bez it returns only one row , with 0.003 cost , but others returm more than one row and consequently do more IO
-if query return less rows , that is best IO
so, don't bother yourself with "=" or "<>"