peter.cox (6/27/2014)
hianyone got an idea for a CTE that takes a string, and puts it into a table with the words in any order.
so the variable would be 'tesco mixed fruit'
and the data column in the table would be
tesco mixed fruit
mixed fruit tesco
fruit tesco mixed
mixed tesco fruit
fruit mixed tesco
tesco fruit mixed.
easy enough to split - which I'd thought was the requirement! - but it's taken on a new level of complexity...
thanks
Now that you have a couple of possible solutions, why do you need to do this? What's the business reason?
p.s. That WHILE loop cleverly disguised as a recursive CTE probably isn't the best idea for a splitter.
--Jeff Moden
Change is inevitable... Change for the better is not.