make a function like belowCREATE FUNCTION dbo.concat_values ( @item INT,@Description VARCHAR(1000) )RETURNS VARCHAR(8000) AS BEGIN DECLARE @p VARCHAR(8000) ; SET @p = '' ; SELECT @p = @p + Location + ',' FROM YourTable WHERE Itemcode = @item AND Description=@Description RETURN @p END
And, as for its usage: SELECT Itemcode,Description,dbo.concat_values(Itemcode,Description ) AS LocationFROM YourTableGROUP BY Itemcode,Derscription