Here the code from my function:
-- Get Country Names
DECLARE getCountriesName CURSOR FOR
SELECT c.Name
FROM VocabCountry c
RIGHT OUTER JOIN ProjectCountryRelations cr
ON cr.CountryId = c.Id
WHERE
c.Id = @project_id;
-- Finally Create list to return
OPEN getCountriesName;
FETCH NEXT FROM getCountriesName INTO @Name;
WHILE @@FETCH_STATUS = 0
BEGIN
SET @listOfItems = @listOfItems + @Name + ', '
FETCH NEXT FROM getCountriesName INTO @Name;
END;
CLOSE getCountriesName;
DEALLOCATE getCountriesName;
I am expecting a list of comma separated values, for example, like so:
Canada, United States of America,
I verified that the SELECT returns the countries expected.
Thanks for any help!
Eric
@listOfItemsto anything before the loop?NULL(as would @MikaelEriksson, I think)