SQL Server: Difference between != and <> Operator used for NOT EQUAL TO Operation

SQL – Difference between != and Operator used for NOT EQUAL TO Operation

Here is interesting question received on my Facebook page. (On a side note, today we have crossed over 50,000 fans on SQLAuthority Facebook Fan Page).
What is the difference between != and Operator in SQL Server as both of them works same for Not Equal To Operator? 
Very interesting question indeed. Even though this looks very simple when I asked quite a few people if they know the answer before I decided to blog about it. The answer which I received was that it seems that many know the answer but everybody wanted to know the more about it.
Here is the answer – Technically there is no difference between != and . Both of them work the same way and there is absolutely no difference in terms of performance or result.
Here is the follow up question I received right I answer that there is no difference between those operator.
If != and both are the same, which one should be used in SQL queries?
Here is the answer – You can use either != or both in your queries as both technically same but I prefer to use as that is SQL-92 standard.
Though, many of the leading database applications supports both of the operators. For example –
  • SQL Server
  • MySQL
  • Oracle
  • SQLite
  • Sybase
  • IBM Informix
  • PostgreSQL
Here is my return question to you which one of the following operators you use for NOT EQUAL TO operation?
  1. !=
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s