I am trying to update column in the same table where my SELECT below is returning the results. The name of the column to update is ID with 'AfterString' result from the select.
My select which returns the data I want in 'AfterString' field:
SELECT
RIGHT(CODE,len(CODE)-charindex('@',CODE)) as AfterString
FROM dbo.LOG
WHERE charindex('@',CODE)<>0
I am not sure how to map it row to its correspondent row in the same table.
To update the same exact row where the AfterString
data is coming from:
update dbo.LOG
set ID = RIGHT(CODE,len(CODE)-charindex('@',CODE))
where charindex('@',CODE)<>0