Sqlserver
 sql >> Datenbank >  >> RDS >> Sqlserver

Teilen Sie eine Zeichenfolge in Sql Server 2005 in einzelne Zeichen auf

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