I am running the following code. The code does not loop through all the records that are there in the @result. What is the correct syntax. Do I have to use counter in this case? I want it to be flexible so it print all values that are there in the variable.
declare @result varchar(1000)
select @result = item from items
while @result != ''
begin
print @result
end
Select item from items
result in this query

What I am getting from print is an endless loop that I have to manually stop and it prints this …
small bed
small bed
small bed
small bed
What is decent way to print all values in the variable. I am talking about text data only, not numbers.
You could use a cursor to iterate over all of the data returned from your query.