Well here is my solution. since we can order by when we take our substring we can just put the FOR XML PATH ('') in that query and not have to worry about any tags.
DECLARE @num INT = 102948092
DECLARE @NumString VARCHAR(10)
SET @NumString=@num
;WITH e1(N) AS (SELECT 1 FROM (VALUES (1),(1),(1),(1),(1),(1),(1),(1),(1),(1)) X(N)),
e2(N) AS (SELECT 1 FROM e1 a, e1 b),
cteTally(N) AS (SELECT ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) FROM e2)
SELECT SUBSTRING(@NumString,N,1)
FROM cteTally
WHERE N <= DATALENGTH(@NumString)
ORDER BY N DESC
FOR XML PATH ('')
For performance Issues see how we like them posted here: How to Post Performance Problems - Gail Shaw[/url]
Need to Split some strings? Jeff Moden's DelimitedSplit8K[/url]
Jeff Moden's Cross tab and Pivots Part 1[/url]
Jeff Moden's Cross tab and Pivots Part 2[/url]