Expressions

  • mister.magoo

    SSC-Forever

    Points: 47068

    Comments posted to this topic are about the item Expressions

    MM



    select geometry::STGeomFromWKB(0x0106000000020000000103000000010000000B0000001000000000000840000000000000003DD8CCCCCCCCCC0840000000000000003DD8CCCCCCCCCC08408014AE47E17AFC3F040000000000104000CDCCCCCCCCEC3F9C999999999913408014AE47E17AFC3F9C99999999991340000000000000003D0000000000001440000000000000003D000000000000144000000000000000400400000000001040000000000000F03F100000000000084000000000000000401000000000000840000000000000003D0103000000010000000B000000000000000000143D000000000000003D009E99999999B93F000000000000003D009E99999999B93F8014AE47E17AFC3F400000000000F03F00CDCCCCCCCCEC3FA06666666666FE3F8014AE47E17AFC3FA06666666666FE3F000000000000003D1800000000000040000000000000003D18000000000000400000000000000040400000000000F03F000000000000F03F000000000000143D0000000000000040000000000000143D000000000000003D, 0);

  • Forum Etiquette: How to post Reporting Services problems
  • [/url]
  • Forum Etiquette: How to post data/code on a forum to get the best help - by Jeff Moden
  • [/url]
  • How to Post Performance Problems - by Gail Shaw
  • [/url]

  • james.of.rivendell

    Old Hand

    Points: 387

    Moral of today's question. Be careful when using indeterministic functions inside nullif...

  • Vinay Kumar

    SSCertifiable

    Points: 6098

    :Whistling: i have taken more time to answer this and learn something new.

    Thanks MM

    Thanks
    Vinay Kumar
    -----------------------------------------------------------------
    Keep Learning - Keep Growing !!!

  • Koen Verbeeck

    SSC Guru

    Points: 258965

    Very nice question. Thanks.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • SQLWinther

    SSCertifiable

    Points: 5946

    Nice "tricky" question! Thank you!

    /Hรฅkan Winther
    MCITP:Database Developer 2008
    MCTS: SQL Server 2008, Implementation and Maintenance
    MCSE: Data Platform

  • kapil_kk

    SSC-Insane

    Points: 21316

    Koen Verbeeck (8/7/2013)


    Very nice question. Thanks.

    +1 ๐Ÿ™‚

    _______________________________________________________________
    To get quick answer follow this link:
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

  • mickyT

    SSChampion

    Points: 10360

    Nice question thanks

  • ok181ko

    SSC Rookie

    Points: 35

    How about

    newid() = '00000000-0000-0000-0000-000000000000'

    The question is not correct. Answer is 0 (zero).

  • Carlo Romagnano

    SSC-Insane

    Points: 21987

    Very good explanation!

    Here is why the first select may return 1,-1,negative and the second only 1 and negative.

    The same side effect of "C" macros:

    #define abs(a) (a < 0? a*-1: a )

    int a = 1;

    print("Result %d",abs(++a));

    Result 3

    select

    isnull(

    nullif( convert( varchar, sign( checksum( upper(newid()) ) ) ), '-1' )

    , 'negative'

    )

    declare @U uniqueidentifier = newid()

    select

    isnull(

    nullif( convert( varchar, sign( checksum( @U ) ) ), '-1' )

    , 'negative'

    )

    go 10

  • paul.knibbs

    SSCoach

    Points: 15270

    ok181ko (8/8/2013)


    How about

    newid() = '00000000-0000-0000-0000-000000000000'

    The question is not correct. Answer is 0 (zero).

    The question asked which of the answers were possible outputs of the statement. It never stated that *all* of the possible outputs were listed as answers. Plus, is it even possible for NEWID() to return a value that's all zeroes?

  • Michael Riemer

    SSCertifiable

    Points: 5136

    Definitely learnt something new today! Was very confused at first but a great explanation too - makes it simple. - Thanks.

  • This was removed by the editor as SPAM

  • Michael_Garrison

    Hall of Fame

    Points: 3110

    Dang It! Did it again. I did NOT get my coffee before answering the question. Thus, missed it again. Good question.

  • Hugo Kornelis

    SSC Guru

    Points: 64685

    Good question!

    *kicks self* - I knew this, have been bitten by it before, and STILL managed to get it wrong. Obviously need to be bittenn a lot more before it finally sinks in enough that I don't forget about it anymore... ๐Ÿ˜‰


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/

  • Mark Cowne

    One Orange Chip

    Points: 26754

    Nice question, definitely learned something new.

    ____________________________________________________

    Deja View - The strange feeling that somewhere, sometime you've optimised this query before

    How to get the best help on a forum

    http://www.sqlservercentral.com/articles/Best+Practices/61537
  • Viewing 15 posts - 1 through 15 (of 51 total)

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