It would be as simple as this, as explained in the article:
SELECT t.AID,
Emails = STUFF((SELECT '; ' + t1.EmailID
FROM #TEST1 t1
WHERE t1.AID = t.AID
FOR XML PATH('')), 1, 2, '')
FROM #TEST1 t
GROUP BY t.AID
ORDER BY t.AID
Luis C.
General Disclaimer:
Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?
How to post data/code on a forum to get the best help: Option 1 / Option 2