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

前端 未结 14 1835
失恋的感觉
失恋的感觉 2020-11-22 04:23

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

14条回答
  •  温柔的废话
    2020-11-22 04:58

    !=, despite being non-ANSI, is more in the true spirit of SQL as a readable language. It screams not equal. <> says it's to me (less than, greater than) which is just weird. I know the intention is that it's either less than or greater than hence not equal, but that's a really complicated way of saying something really simple.

    I've just had to take some long SQL queries and place them lovingly into an XML file for a whole bunch of stupid reasons I won't go into.

    Suffice to say XML is not down with <> at all and I had to change them to != and check myself before I riggedy wrecked myself.

提交回复
热议问题