• You don't need a loop to do what you were trying to do. This would do the trick

    DECLARE @emails varchar(5000)=''

    SELECT @emails=@emails+';'+cEmail

    FROM dbo.people;

    This technique, however, can give you data issues... The prefered method would be to use FOR XML PATH as discussed in the link Louis provided....

    SELECT x FROM

    (SELECT cEmail + ';'

    FROM #people

    FOR XML PATH('')) xx(x)

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001