• Some time mind doesn't working to get easy logic

    Here is the way i achieved.

    select

    stuff

    (

    coalesce(', ' + cast(@id1 as varchar(10)), '') +

    coalesce(', ' + cast(@id2 as varchar(10)), '') +

    coalesce(', ' + cast(@id3 as varchar(10)), '') , 1, 2, ''

    ) as result