Split a set of contiguous string into individual characters/letters using CTE

Niladri.Biswas
Posted by Niladri.Biswas under Sql Server category on | Points: 40 | Views : 862
Declare @str Varchar(50) = 'abcde'
;With NumCte As
(
Select Number = 1 Union All
Select Number +1 From NumCte
Where Number < 1000
)
Select
Data = Substring(@str,Number,1)
From NumCte
where Number Between 1 And Len(@str)
Option (Maxrecursion 0)

Comments or Responses

Login to post response