NULL

  • Samith C

    Mr or Mrs. 500

    Points: 519

    Comments posted to this topic are about the item NULL

    [font="Verdana"] There is no Wrong time to do a Right thing 🙂 [/font]

  • Lokesh Vij

    SSChampion

    Points: 10836

    An easy one! NULL means a value unknown or not defined yet, it may be equal to or may not be equal to 'Kannur'....Hence NULLS disappear from equality and inequality operations. They are handled separately 🙂

    BTW...thanks for this refreshing question though!

    ~ Lokesh Vij


    Guidelines for quicker answers on T-SQL question[/url]
    Guidelines for answers on Performance questions

    Link to my Blog Post --> www.SQLPathy.com[/url]

    Follow me @Twitter

  • rVadim

    Hall of Fame

    Points: 3969

    Thank you for a nice easy question.

    But I'm not sure about explanation (or maybe I'm just reading it wrong):

    The Null value also matches the condition in case of Not Operators (<>,Not in ,Not like..) since it could possibly be a match.

    I think any comparison against NULL will yield Unknown, which is not True, and therefore records won't be returned.

    --Vadim R.

  • Lokesh Vij

    SSChampion

    Points: 10836

    rVadim (8/14/2012)


    I think any comparison against NULL will yield Unknown, which is not True, and therefore records won't be returned.

    +1

    Yes that's correct!

    ~ Lokesh Vij


    Guidelines for quicker answers on T-SQL question[/url]
    Guidelines for answers on Performance questions

    Link to my Blog Post --> www.SQLPathy.com[/url]

    Follow me @Twitter

  • Stuart Davies

    SSCoach

    Points: 18878

    Easy question and point today - thanks

    -------------------------------Posting Data Etiquette - Jeff Moden [/url]Smart way to ask a questionThere are naive questions, tedious questions, ill-phrased questions, questions put after inadequate self-criticism. But every question is a cry to understand (the world). There is no such thing as a dumb question. ― Carl Sagan I would never join a club that would allow me as a member - Groucho Marx

  • This was removed by the editor as SPAM

  • honza.mf

    SSCertifiable

    Points: 5519

    Lokesh Vij (8/14/2012)


    rVadim (8/14/2012)


    I think any comparison against NULL will yield Unknown, which is not True, and therefore records won't be returned.

    +1

    Yes that's correct!

    +1

    And even worse the answer is incorrect with ANSI NULLS off.



    See, understand, learn, try, use efficient
    © Dr.Plch

  • SQL Surfer '66

    SSCertifiable

    Points: 5159

    Interesting. Thanks for this one.

  • Gazareth

    One Orange Chip

    Points: 27737

    honza.mf (8/15/2012)


    Lokesh Vij (8/14/2012)


    rVadim (8/14/2012)


    I think any comparison against NULL will yield Unknown, which is not True, and therefore records won't be returned.

    +1

    Yes that's correct!

    +1

    And even worse the answer is incorrect with ANSI NULLS off.

    I did spend some time checking to see if there were any clues as to whether ANSI NULLS was on or off before I answered!

  • (Bob Brown)

    SSCrazy

    Points: 2705

    Thanks for a nice easy question to celebrate the midweek.

  • Thomas Abraham

    SSChampion

    Points: 10761

    Samith, thanks for contributing! Always interesting, and potentially contentious, when NULLs are brought up. But, good to keep thinking of them.

    [font="Verdana"]Please don't go. The drones need you. They look up to you.[/font]
    Connect to me on LinkedIn

  • sestell1

    SSChampion

    Points: 10230

    Nice question. This trips up a lot of people new to SQL and seems to lead to a lot of negative feelings towards NULL values.

    (NULLs aren't bad, they're just often misunderstood!!)

  • mtassin

    SSC-Insane

    Points: 23099

    sestell1 (8/15/2012)


    Nice question. This trips up a lot of people new to SQL and seems to lead to a lot of negative feelings towards NULL values.

    (NULLs aren't bad, they're just often misunderstood!!)

    Totally agree. 🙂

    I actually love NULLS, but then again I'm more familiar with them my devs are.

    The sad thing are the number of tables with NULLable columns, but the apps explode when the data is actually NULL because the guys who made the database 10 years before I started didn't handle NULL correctly, or didn't make the column NOT NULL.

    Ah one day we'll get them all cleaned up... 80 databases.... over 1500 tables used by nearly 50 applications.... probably not soon.



    --Mark Tassin
    MCITP - SQL Server DBA
    Proud member of the Anti-RBAR alliance.
    For help with Performance click this link[/url]
    For tips on how to post your problems[/url]

  • mtassin

    SSC-Insane

    Points: 23099

    honza.mf (8/15/2012)


    Lokesh Vij (8/14/2012)


    rVadim (8/14/2012)


    I think any comparison against NULL will yield Unknown, which is not True, and therefore records won't be returned.

    +1

    Yes that's correct!

    +1

    And even worse the answer is incorrect with ANSI NULLS off.

    At leats this thankfully won't be an issue sooner or later. SET ANSI NULLS OFF will throw an error in a coming SQL Release.

    http://msdn.microsoft.com/en-us/library/ms188048.aspx



    --Mark Tassin
    MCITP - SQL Server DBA
    Proud member of the Anti-RBAR alliance.
    For help with Performance click this link[/url]
    For tips on how to post your problems[/url]

  • SQLRNNR

    SSC Guru

    Points: 281243

    EZPZ

    Thanks

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

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

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