conditional line feed

  • I concantenate several columns and would like to do a line feed

    only if the column value is not null. This does not work within the concantenation. Is there any way to do this?

     IsNull(@RbrComm,'') +

     IF @RBrComm Is Not Null

      CHAR(13) + CHAR(10) +

    Thanks so much,

    Sam

  • NULL concatenated with anything is still NULL if the default setting of "Concatenate Null Yields Null" was left on... so this simple ditty will do the job you asked...

    IsNull(@RbrComm+CHAR(13)+CHAR(10),'')

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

  • You've helped me several times, Jeff. Thanks!

Viewing 3 posts - 1 through 2 (of 2 total)

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