<> is Standard SQL-92; != is its equivalent. Both evaluate for values, which NULL is not -- NULL is a placeholder to say there is the absence of a value.
Which is why you can only use IS NULL/IS NOT NULL as predicates for such situations.
This behavior is not specific to SQL Server. All standards-compliant SQL dialects work the same way.
Note: To compare if your value is not null, you use IS NOT NULL, while to compare with not null value, you use <> 'YOUR_VALUE'. I can't say if my value equals or not equals to NULL, but I can say if my value is NULL or NOT NULL. I can compare if my value is something other than NULL.
sql - Not equal <> != operator on NULL - Stack Overflow
sql server - Should I use != or <> for not equal in T-SQL? - Stack Overflow
help in finding an equal sign that is not surrounded by a whitespace
Need some knowledge on NULL and NOT NULL
Videos
<> is Standard SQL-92; != is its equivalent. Both evaluate for values, which NULL is not -- NULL is a placeholder to say there is the absence of a value.
Which is why you can only use IS NULL/IS NOT NULL as predicates for such situations.
This behavior is not specific to SQL Server. All standards-compliant SQL dialects work the same way.
Note: To compare if your value is not null, you use IS NOT NULL, while to compare with not null value, you use <> 'YOUR_VALUE'. I can't say if my value equals or not equals to NULL, but I can say if my value is NULL or NOT NULL. I can compare if my value is something other than NULL.
NULL has no value, and so cannot be compared using the scalar value operators.
In other words, no value can ever be equal to (or not equal to) NULL because NULL has no value.
Hence, SQL has special IS NULL and IS NOT NULL predicates for dealing with NULL.
Most databases support != (popular programming languages) and <> (ANSI).
Databases that support both != and <>:
- Apache Derby 10.16:
!=and<> - IBM Informix Dynamic Server 14.10:
!=and<> - InterBase/Firebird:
!=and<> - Microsoft SQL Server 2000/2005/2008/2012/2016:
!=and<> - Mimer SQL 11.0:
!=and<> - MySQL 8.0.33:
!=and<> - Oracle 23c:
!=and<> - PostgreSQL 15:
!=and<> - SQLite:
!=and<> - Sybase Adaptive Server Enterprise 16.0:
!=and<>
Databases that support the ANSI standard operator, exclusively:
- IBM DB2 UDB 9.5:
<> - Microsoft Access 2010:
<>
Technically they function the same if you’re using SQL Server AKA T-SQL. If you're using it in stored procedures there is no performance reason to use one over the other. It then comes down to personal preference. I prefer to use <> as it is ANSI compliant.
You can find links to the various ANSI standards at...
http://en.wikipedia.org/wiki/SQL