declare @mav varchar(max) select @mav=coalesce(@mav+', '+d.Name,d.Name) from ( select Name from HumanResources.Department) d order by d.Name select @mav