T-SQL Split Word into characters
Here you have it:
create table #words (
character varchar(1)
)
declare @test varchar(10)
select @test = 'QWERTY'
declare @count int, @total int
select @total = len(@test), @count = 0
while @count <= @total
begin
insert into #words select substring(@test, @count, 1)
select @count = @count + 1
end
select * from #words
drop table #words
Declare @word nvarchar(max)
Select @word = 'Hello This is the test';
with cte (Number)as
(Select 1
union all
select Number +1 From cte where number <len(@word)
)
select * from Cte Cross apply (Select SUBSTRING(@word,number,1 ) ) as J(Letter)
Do it like this:
select substring(a.b, v.number+1, 1)
from (select 'QWERTY AnotherWord' b) a
join master..spt_values v on v.number < len(a.b)
where v.type = 'P'