lunes, 2 de diciembre de 2013

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

Reference: Pinal Dave (http://blog.sqlauthority.com)

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. !=
  2. <>
Please leave your answer with reason in comment field and I will publish the interesting answer as a follow up blog post with due credit.

Todos los Sábados a las 8:00PM

Optimismo para una vida Mejor

Optimismo para una vida Mejor
Noticias buenas que comentar