Database

Reverse Substring

This query searches from right > left to find the first space then inserts a "-" in there (:source lang=sql :) update action set action_disp = SUBSTRING(Action_Disp, 0, len (Action_disp) - CHARINDEX(' ', Reverse(action_Disp), 5)+1 ) + ' -' + Right(action_Disp, CHARINDEX(' ', Reverse(action_Disp), 5)-1)

This one does the same but removes any "-" chars from the string before inserting the -

(:source lang=sql :) update action set action_disp = SUBSTRING(Action_Disp, 0, len (Action_disp) - CHARINDEX(' ', Reverse(action_Disp), 5)+1 ) + ' -' + Replace(Right(action_Disp, CHARINDEX(' ', Reverse(action_Disp), 5)-1), '-', '')