|Depends what you mean by "better".
You're using SQL 2016, so STRING_AGG[^] is out - that was added in 2017.
But you can use STRING_SPLIT[^], TRY_PARSE[^], and FORMAT[^]. And there are ways[^] to concatenate row values in 2016 and earlier.
I've assumed a table without a primary key; if your table has one, use that instead of the generated
WITH cteRN As
ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) As RN,
SELECT '.' + IsNull(Format(Try_Parse(P.value As int), 'D2'), P.value)
FROM cteRN As T2
CROSS APPLY string_split(T2.tree, '.') As P
WHERE T2.RN = T.RN
FOR XML PATH(''), TYPE
, 1, 1, '') As tree
cteRN As T
; It's not pretty, but it works:
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
General News Suggestion Question Bug Answer Joke Praise Rant Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.