Should I use != or <> for not equal in T-SQL?

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


Most databases support != (popular programming languages) and <> (ANSI).

Databases that support both != and <>:

  • MySQL 5.1: != and <>
  • PostgreSQL 8.3: != and <>
  • SQLite: != and <>
  • Oracle 10g: != and <>
  • Microsoft SQL Server 2000/2005/2008/2012/2016: != and <>
  • IBM Informix Dynamic Server 10: != and <>
  • InterBase/Firebird: != and <>
  • Apache Derby 10.6: != and <>
  • Sybase Adaptive Server Enterprise 11.0: != and <>
  • Mimer SQL 11.0: != and <>

Databases that support the ANSI standard operator, exclusively:

  • IBM DB2 UDB 9.5: <>
  • Microsoft Access 2010: <>