How to get individual character from a string of characters?

Niladri.Biswas
Posted by Niladri.Biswas under Sql Server category on | Points: 40 | Views : 651
declare @str varchar(100)
set @str = '123456788997877'

--Build a number table
declare @tblNumber table(num int)
insert into @tblNumber values(1)
insert into @tblNumber values(2)
insert into @tblNumber values(3)
insert into @tblNumber values(4)
insert into @tblNumber values(5)
insert into @tblNumber values(6)
insert into @tblNumber values(7)
insert into @tblNumber values(8)
insert into @tblNumber values(9)
insert into @tblNumber values(10)
insert into @tblNumber values(11)
insert into @tblNumber values(12)
insert into @tblNumber values(13)
insert into @tblNumber values(14)
insert into @tblNumber values(15)

select IndiChars = substring(@str,num,1) from @tblNumber

Comments or Responses

Login to post response