By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE testdata (
LicenseNumberList VARCHAR(100),
ItemNumberList VARCHAR(100)
);
-- Insert data
INSERT INTO testdata (LicenseNumberList, ItemNumberList)
VALUES ('[1234],[8854],[6987]', '[4555,8777,4444],[4415],[4444]');
1 rows affected
SELECT
LicenseNumberList = TRIM('[] ' FROM lnl.value),
ItemNumberList = TRIM('[] ' FROM inl.value)
FROM testdata td
CROSS APPLY STRING_SPLIT(REPLACE(td.LicenseNumberList, '],[', '|'), '|', 1) lnl
CROSS APPLY STRING_SPLIT(REPLACE(td.ItemNumberList, '],[', '|'), '|', 1) inl
WHERE lnl.ordinal = inl.ordinal;
LicenseNumberList | ItemNumberList |
---|---|
1234 | 4555,8777,4444 |
8854 | 4415 |
6987 | 4444 |