2

I was working in MSSQL server 2012. I wrote a query

select * from Mytable where col1 is not null and  col1 != '' 

and

select * from Mytable where col1 is not null and  col1 <> ''

Both returns same value. I am just curious to know, what is the actual difference between <> and != operators?

2
  • Thanks. I searched the question in stackoverflow and I could not get it. So I posted this question. But this question is duplicated:-) Commented Feb 26, 2014 at 5:51
  • They're both not equal, which is to say they're equivalent to each other... Here are handy alternatives too: WHERE NULLIF(col1,'') IS NOT NULL or WHERE ISNULL(col1,'') <> '' Commented Feb 26, 2014 at 5:51

3 Answers 3

4

My understanding is that there is no difference. The <> operator is the ANSI SQL standard inequality operator, while Microsoft included != to make it like some programming languages.

Sign up to request clarification or add additional context in comments.

Comments

3

!= is not ANSI compliant.
That's all.
Use <>

UPD. Oh, here

Comments

1

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.