**MyTable**
*myColumn*
/A/B/C/XYZ
/A/B/C/abc
...
/A/B/C/whatever is not fixed and is dynamic and need to replaced with something like /1/2/3/whatever, and I like to changed it something like below, keeping the last part after last / intact.
/1/2/3/XYZ
/1/2/3/abc
...
I run the below query
SELECT SUBSTRING(myColumn, 0, len(myColumn) - CHARINDEX('/',REVERSE(myColumn)) +1 )
FROM MyTable
that correctly returns the part that need to be replaced
/A/B/C
/A/B/C
/A/B/C
...
The generic update is that I understood from UPDATE and REPLACE part of a string is
Update MyTable SET myColumn = REPLACE(myColumn, '/A/B/C','/1/2/3')
So my final query to update and replace is
Update MyTable
SET myColumn = REPLACE(myColumn,
(SELECT SUBSTRING(myColumn, 0, len(myColumn) - CHARINDEX('/',REVERSE(myColumn)) +1 )
FROM MyTable),
'/1/2/3')
but it gives the below error
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
I suspect that the output of my subquery doesn't contain the quotes '...' , how to put that or what else is the issue?