SQL Server - Cocatenate values in string - Asked By jason barry on 14-Nov-12 03:09 AM

This is my string, it will either return two results.


.Surname + ',' + ' ' + rnl.FirstName + isnull(nullif(', ' + nullif(isnull(RNL.Honours,''),',') +


(isnull(RNL.Awards,''),',') + nullif(isnull(RNL.Degree,''),','),', '),'') as 'Name',

Result a - DOE1582, John Smith              ----no qualifications or awards for this person
Result b - DOE1599, John Peter,   M of Sci, GradDipCompSt, BSc

Is it possible to modify the code to put a '(' around the honours and Awards), and if there are no honours or awards against this person, do not display the (opn and closed brackets)....

So for example

Yes - Result - DOE1599, John Peter, (M of Sci, GradDipCompSt), BSc
No - Result - DOE1599, John Peter, (), BSc

Is this possible, i am not sure if I can fit anymore into the above code.
Robbe Morris replied to jason barry on 14-Nov-12 08:08 AM

select case when colA = 'stuff' then '(some stuff') else 'some other stuff' end as myColumnA
 from tableA