REPLACE() and NULL

  • Comments posted to this topic are about the item REPLACE() and NULL

    -----
    a haiku...

    NULL is not zero
    NULL is not an empty string
    NULL is the unknown

  • Nice question ....

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

  • Nice question - 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

  • Nice one...

    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Sometimes, winning is not an issue but trying.
    You can check my BLOG
    [font="Arial Black"]here[/font][/url][/right]

  • thnx nice one 🙂

    SELECT REPLACE('Hello world',NULL, 'zzz' );

    as suggested by you... even this returns the same output

  • [p]I learnt new thing today. Thanks Ronmoses.[/p]

    KSB
    -----------------------------
    Thousands of candles can be lit from a single candle, and the life of the candle will not be shortened. Knowledge and happiness never decreases by being shared.” - Buddha

  • [font="Verdana"]Goodish! simple and informative!

    [/font]

  • Good question. i like this function. Have used it

  • A simple question, but a usefull one nonetheless, especially if you use the function with variables as input parameters.

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

  • This is one of those things that can be a real gotcha if you don't know about it, and put in code to handle it ahead of time. Thanks.

  • Nice question.

    Converting oxygen into carbon dioxide, since 1955.
  • Anyone got any ideas why this function was made to work this way? Makes no sense to me.

  • kevin.l.williams (7/12/2010)


    Anyone got any ideas why this function was made to work this way? Makes no sense to me.

    I cannot answer that authoritatively, but consider that it would make no sense to try to replace part of a string with NULL either, so perhaps the decision was made to check the types of all three parameters first before doing the matching.

    --

    edit: fix typo

  • Good question.

    Also, thanks John Arnott for the explanation. It makes sense.

  • KevinC. (7/12/2010)


    It makes sense.

    Really? Would it have been too difficult to return the string unmodified if there was a NULL detected? In the way it is now, a small bug can be disastrous, potentially wiping out critical data.

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

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