Avoiding cursors, but...

  • Calvin,

    If your server is set to CONCATENIZATION OF NULL YIELDS NULL, then you will need either COALESCE or ISNULL unless you preset the variable to something other than NULL.

    --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)
    Intro to Tally Tables and Functions

  • true, or you can use something like this (for a csv, say):

    select @var = isnull(@var + ',', '') + value from table.

    If I dealing with a lot of rows or a query that's run all the time I'll set the variable to and empty string at the beginning.  If not I'll use the isnull, as it looks nicer.

    cl

     

    Signature is NULL

Viewing 2 posts - 16 through 16 (of 16 total)

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