String loop

0

Please login or register to vote for this query.

(click on this box to dismiss)

Gardening and Landscaping Meta

Q&A about the site for gardeners and landscapers

declare @S varchar(max)
set @S = 'in the past 12 months,between 1 and 2 years ago,between 2 and 3 years ago,between 3 and 4 years ago,between 4 and 5 years ago,between 5 and 6 years ago,between 6 and 10 years ago,between 3 and 6 years ago,over 6 years ago,over 10 years ago,in the past 3 years'

while len(@S) > 0
begin
  print left(@S, charindex(',', @S+',')-1)
  set @S = stuff(@S, 1, charindex(',', @S+','), '')
end

Enter Parameters

Options:
Switch to main site
loading Hold tight while we fetch your results