By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
create table test (
col1 varchar(100),
col2 varchar(100)
)
insert into test (col1,col2) values ('1,2,3,4','1,2,3,4')
select * from (
select value as Col1 from test
CROSS APPLY STRING_SPLIT(replace(replace(Col1,'[',''),']',''),',')
)a
left join (
select value as Col2 from test
CROSS APPLY STRING_SPLIT(replace(replace(Col2,'[',''),']',''),',')
)b on a.col1 =b.col2
Col1 | Col2 |
---|---|
1 | 1 |
2 | 2 |
3 | 3 |
4 | 4 |