By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
declare @s varchar(100)='This approach is traditional, and is supported in all versions and editions of SQL Server';
select String_Agg(string,' ') within group (order by seq)
from (
select j.[value] string, Iif(j.[key] % 2 = 1, Lag(seq) over(order by seq) ,seq) gp, seq
from OpenJson(Concat('["',replace(Replace(@s,',',' ,'), ' ', '","'), '"]')) j
cross apply(values(Convert(tinyint,j.[key])))x(seq)
)x
group by gp;
(No column name) |
---|
This approach |
is traditional |
, and |
is supported |
in all |
versions and |
editions of |
SQL Server |