Phil,
I tried using a function which gives comma separated into
table valued fun.
set @SelPorts=N'[EMBIDIV],[AMEX],[AMR]'
Select * from (select Por.ShortName, IsNull(IsNull(SM.SecDesc, rtrim(SM.SecName)), SM.PrimarySecID) as SecName,
SM.SecID,IsNull(SM.BBSectorName, 'zOthers') AssetClass...