http://stackoverflow.com/questions/10199927/find-chars-in-any-order-in-sql-server

0

Please login or register to vote for this query.

(click on this box to dismiss)

Open Source Meta

Q&A about the site for people organizing, marketing or licensing open source development projects

DECLARE @t AS TABLE (search varchar(100));

INSERT INTO @t VALUES ('avi');

;with cte as
(
  select substring(search, 1, 1) as Chars,
         stuff(search, 1, 1, '') as search,
         1 as RowID
  from @t
  union all
  select substring(search, 1, 1) as Chars,
         stuff(search, 1, 1, '') as search,
         RowID + 1 as RowID
  from cte
  where len(search) > 0
)
select RowID, Chars
from cte
order by RowID

Enter Parameters

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