I trying to replace text between the first two forward slash "/" in my datacolumn.
I have the following which allows me to get everything before.
Select ReportLocation, substring(ReportLocation, 0, Len(ReportLocation)-charindex ('/', reverse(ReportLocation)) +2) from Report
Then I tried this which changes all the data in the column to the same.
Declare @Url varchar(max)
SELECT ReportLocation
,LEFT(ReportLocation, CHARINDEX('/', ReportLocation) - 0) AS [Surname]
,REPLACE(SUBSTRING(ReportLocation, CHARINDEX('/', ReportLocation), LEN(ReportLocation)), '/', 'newone') AS ReportLocation
FROM Report
where CHARINDEX('/', ReportLocation) > 0
What I am looking for is some that can replace text between the first two '/'
example:
Column Name: ReportLocation
record 1 in Column: /123/abc/987
record 2 in Column: /xyz/123/456/478
In record 1 the following should happen record /123/abc/987. 123 should be replace with what name I add, record 2 /xyz/123/456, xyz should be hould be replace with what name I add
Thanks a head of time.