Recently i have read your post regarding Tally Table.So we can replace your part of the code with following code:
select substring(@s,number,1) as number from
select number from master..spt_values
where type='p' and number between 1 and len(@s)
) as t
SELECT SUBSTRING(@s,N,1) FROM TALLY WHERE N<=LEN(@s)
NOTE: Tally table should exists.
Thanks for your original post.
commented on Jun 13 2013 1:06AM