Using SQL Server 2022, attempt to create a computed column for indexing/queries on the 3rd part of a string separated by slashes (it's a URI).
ALTER TABLE MyTable
ADD SpotName AS (CAST((SELECT Value FROM STRING_SPLIT(FullUri, '/', 7)) AS VarChar(128))) PERSISTED
And the error I get is:
Subqueries are not allowed in this context. Only scalar expressions are allowed.
I want to do this for 5 different parts of URIs, so what is a smart way to index/optimize queries for different substring parts?
Thanks.