Null question

  • Hi,

    I have a question related with NULLs.

    Can you please help?

    Thanks in advance.

    My question is (when SQL Server installed with the default options) how does SQL Server 2005 behavior is , in this case:

    if test1 returns Null, the result of the select will be null, correct?

    e.g:

    select test1+isnull(test2,'')

    question:

    If i concatenate a null value with some other value (not null), will the result allways be a null?

  • http://technet.microsoft.com/en-us/library/ms176056(SQL.90).aspx

    ----------------------------------------------------------------------------------------------------------------------------------------------------
    Roshan Joe

    Jeff Moden -Forum Etiquette: How to post data/code on a forum to get the best help[/url]

  • thanks for the tip.

  • Note that the option will be removed from a future version of SQL.

    IMO if you have a nullable field in a concatanation then you should always stick isnulls round each part.

  • Will that be removed allready in SQL Server 2008?

    Or only in future versions?

    Thank you

  • Pass, the link to the technet site seems to be for 2005 documentation, so there is a chance its been removed from 2008 although i dont have a 2008 server to test on.

  • Use COALESCE to get rid of null values.

  • dba_pkashyap (11/25/2009)


    Use COALESCE to get rid of null values.

    Why? Is it because you believe in the myth of portability? Unless I have more than 1 operand to check for a null value, I use ISNULL in SQL Server because it's faster than COALESCE. Most people won't notice the difference but my batches consist of queries on tables where each table will contain millions of rows. Shoot, I've got "simple" lookup tables that necessarily consist of more than 500,000 rows and every microsecond saved on a row works out to be a substantial savings on the batches.

    --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)

Viewing 8 posts - 1 through 7 (of 7 total)

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