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'); DECLARE @words AS TABLE (word varchar(100)); INSERT INTO @words VALUES ('avion'), ('iva'), ('name'); 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