• You could use either CASE or ISNULL or COALESCE for such a thing. I used ISNULL in the following example. Also, you would do better for yourself if you provided your data as readily consumable data so people can test their answer before posting it. See the first link in my signature below for an article on how to do that correctly.

    SELECT RTRIM(

    + 'ColA:'+ISNULL(ColA,'')+', '

    + ISNULL('ColB:'+CAST(ColB AS VARCHAR(10))+' ','')

    + ISNULL('ColC:'+CAST(ColC AS VARCHAR(10))+' ','')

    + ISNULL('ColD:'+CAST(ColD AS VARCHAR(10))+' ','')

    )

    FROM

    ( --=== Similation of your table. Use your table name here

    SELECT 'Admin',NULL,NULL,NULL UNION ALL

    SELECT 'Market',101,256,258 UNION ALL

    SELECT 'Sales',205,125,NULL UNION ALL

    SELECT 'Admin',256,258,548

    )d(ColA,ColB,ColC,ColD)

    ;

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