Selecting between two fields

  • I used this funtion in the past, but now the name escapes me.

     

    What it does is wrap two  columns and if the first column is empty it selects the contents of the second.

     

    If anyone can remember the name plese pass it along.

     

    thanks on advance

    --Ron

  • declare @table table

    (

    some_value varchar(50),

    some_other_value varchar(50),

    some_other_other_value varchar(50)

    )

    insert @table

    select NULL,NULL,'easy'

    union all

    select NULL,'as','abc'

    union all

    select '123',NULL,'abc'

    union all

    select NULL,NULL,NULL

    select coalesce(some_value,some_other_value,some_other_other_value,'Nothing there')

    from @table


    Mathew J Kulangara
    sqladventures.blogspot.com

  • Thank you

    --Ron

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

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