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

Bob The Janitor picture Bob The Janitor · Apr 6, 2009 · Viewed 1.1M times · Source

I have seen SQL that uses both != and <> for not equal. What is the preferred syntax and why?

I like !=, because <> reminds me of Visual Basic.

Answer

Bill Karwin picture Bill Karwin · Apr 7, 2009

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

Databases that support both != and <>:

Databases that support the ANSI standard operator, exclusively:

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