In the code below, the statement 'Print @Sites' prints nothing, even
though the cursor contains 4 records, and 'Print @Site' prints the
appropriate values. Can anyone see my mistake? I am attempting to
print a delimited string of the values referred to by @Sites.
Thanks.
Dan Fisherman
DECLARE SiteCursor CURSOR
GLOBAL
SCROLL
STATIC
FOR SELECT OfficeName FROM ClientOffices WHERE ClientID=12 ORDER BY
OfficeName
OPEN SiteCursor
DECLARE @Sites varchar(1000)
DECLARE @Site varchar(100)
FETCH NEXT FROM SiteCursor INTO @Site
WHILE @@FETCH_STATUS=0
BEGIN
print @Site
SET @Sites = @Sites + ', ' + @Site
FETCH NEXT FROM SiteCursor INTO @Site
END
PRINT @Sites
CLOSE SiteCursor
DEALLOCATE SiteCursor
GO