is there any difference between != and <>

  • Pls tell me

    karthik

  • I think they are the same

    Pete

    Peter Gadsby
    Business Intelligence Consultant
    www.hgconsult.co.uk

  • A) <>

    B) !=

    Both mean NOT EQUAL TO but (B) is not SQL 92 standard (The third version of SQL Server)

  • I agree with Mayank... just to add to that, the != will actually appear in execution plans as <>. Sounds strange, but I can always tell who wrote the code if != is used... some Java programmer 😉

    The reason I really don't like it is because 1) it's not what I'm accustomed to for identifying an inequality (used to <> because of Math) and 2) for some reason, it's hard for me to see when I'm reviewing code... I guess I just don't think there should be an = sign in an inequality 😉

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Jeff Moden (11/7/2007)


    Sounds strange, but I can always tell who wrote the code if != is used... some Java programmer 😉

    😀 I always use !=, but I'm not a Java programmer. An old habit from my C background... 😉

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Heh... I was going to include "C" programmers in that mix :D, but wasn't sure it was true and I work mostly with Java programmers to boot.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • != is th inequality in C# get used to it as CLR programming takes off!:hehe:

    Hiding under a desk from SSIS Implemenation Work :crazy:

  • Jeff Moden (11/7/2007)The reason I really don't like it is because 1) it's not what I'm accustomed to for identifying an inequality (used to <> because of Math) and 2) for some reason, it's hard for me to see when I'm reviewing code... I guess I just don't think there should be an = sign in an inequality 😉

    The exact opposite for me.

    I learnt != in maths so seeing <> has always been a wtf moment for me.

    Just different notation dialects.

    "!" being a shorthand for the logical NOT operator means != is almost instinctive for me.

    Similarly I use "~" as shorthand for approx* whenever I am writing notes for myself.

  • Shaun McGuile (11/9/2007)


    != is th inequality in C# get used to it as CLR programming takes off!:hehe:

    Heh... good point. But have had this argument with many other folks... there's very little you will ever need a CLR for if you actually know T-SQL well 😉 CLR's are for "C" programmers that don't 😛

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Vincent Chute (11/9/2007)


    The exact opposite for me.

    I learnt != in maths so seeing <> has always been a wtf moment for me.

    Just different notation dialects.

    "!" being a shorthand for the logical NOT operator means != is almost instinctive for me.

    Similarly I use "~" as shorthand for approx* whenever I am writing notes for myself.

    Perfect answer... "Just different notation dialects"...

    Now, using the Tilde to represent approximation is something that I agree with!

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • These all give me the same query plan:

    select * from authors where au_id <> '172-32-1176'

    select * from authors where au_id != '172-32-1176'

    select * from authors where not au_id = '172-32-1176'

  • Heh... also notice that the != gets converted to a <> in the query plan output 😉

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Jeff Moden (11/9/2007)


    Heh... good point. But have had this argument with many other folks... there's very little you will ever need a CLR for if you actually know T-SQL well 😉 CLR's are for "C" programmers that don't 😛

    I'll disagree with you on that point. There's a lot of things that the CLR is better at than T-SQL. String manipulation, complex mathematical calculations, external calls (web service). All far easier and far faster from CLR functions/procs

    Whether or not those belong in the DB in the first place is a different argument. 🙂

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Sting manipulation? Complex mathematical calcs? Heh... Let's have a race... let's start with string manipulation... How about splitting a comma seperated column and returning a table with the PK of each row and the split value... 1 row for every split on a 100k row table? You write a CLR to solve, I'll write the T-SQL to solve. I'll even be happy to provide the test data if you want.

    Or, how about doing Init Caps on a column in a million row table?

    Or, how about removing all characters except digits and letters from a column in a million row table?

    Or, name the problem...

    ...and here's your advantage... I don't have 2k5 to play with... I have to do it using only T-SQL 'cause I only have 2k. 😉

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Jeff you rascal 😀

    Hiding under a desk from SSIS Implemenation Work :crazy:

Viewing 15 posts - 1 through 15 (of 62 total)

You must be logged in to reply to this topic. Login to reply