By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE MyTable(FullUri varchar(500));
INSERT MyTable VALUES ('https://stackoverflow.com/questions/76824564/computed-column-on-split-value');
Alter Table MyTable Add
Part1 As ( Cast(JSON_VALUE('["' + REPLACE(FullUri, '/', '","') + '"]', '$[0]')as VarChar(128))) PERSISTED,
Part2 As ( Cast(JSON_VALUE('["' + REPLACE(FullUri, '/', '","') + '"]', '$[1]')as VarChar(128))) PERSISTED,
Part3 As ( Cast(JSON_VALUE('["' + REPLACE(FullUri, '/', '","') + '"]', '$[2]')as VarChar(128))) PERSISTED,
Part4 As ( Cast(JSON_VALUE('["' + REPLACE(FullUri, '/', '","') + '"]', '$[3]')as VarChar(128))) PERSISTED,
Part5 As ( Cast(JSON_VALUE('["' + REPLACE(FullUri, '/', '","') + '"]', '$[4]')as VarChar(128))) PERSISTED
SELECT *
FROM MyTable
FullUri | Part1 | Part2 | Part3 | Part4 | Part5 |
---|---|---|---|---|---|
https://stackoverflow.com/questions/76824564/computed-column-on-split-value | https: | stackoverflow.com | questions | 76824564 |