HiTry this.. I am using SQL SERVER 2008. If you are using 2005 0r 2000 can you change the Insert statements...so you can create the function and use it select clause. what i have wrote in below statements.CREATE TABLE #temp ( PatientID INT , Allergy VARCHAR(50) )INSERTINTO #temp VALUES ( 1, 'Fish' ) , ( 1, 'Peanuts' ) , ( 2, 'Wheat' ) , ( 2, 'Dairy' ) , ( 3, 'Coconut' )SELECT *FROM #tempDECLARE @COLUMN_ATTRIBUTES VARCHAR(8000)SELECT @COLUMN_ATTRIBUTES=ISNULL(@COLUMN_ATTRIBUTES+',', '')+AllergyFROM dbo.#tempWHERE PatientID= 1SELECT @COLUMN_ATTRIBUTES
-------------------------R..http://code.msdn.microsoft.com/SQLExamples/http://msdn.microsoft.com/hi-in/library/bb500155(en-us).aspx