I have data in table as below and trying to use Replace to do it, but I am ending up with either double semicolon ';;; or semicolon at end after using replace. Can I use split and replace to achieve this or any other ways??
Test attempts;My attempts using operation;Additions, deletions, and modifications
Test attempts;My attempts using operation
Test attempts;access to information;attempts using nex;Additions, deletions, and modifications
Test attempts;Changes to programs
Replace 'My attempts using operation' with emptystring AND Replace 'attempts using nex' with 'attempts using imex' in above data column
Result should be:
Test attempts;Additions, deletions, and modifications
Test attempts-- No semicolon should be there if it ends up at end with that after replace
Test attempts;access to information;attempts using imex;Additions, deletions, and modifications
Test attempts;Changes to programs
REPLACEfunction does not work for you. e.g.SELECT REPLACE(REPLACE(col, ';My attempts using operation', ''), 'attempts using nex;', 'attempts using imex;') FROM mytable;Test attempts;My attempts using operationorTest attempts;My attempts using operation;? In that case just add another replace (e.g.SELECT REPLACE(REPLACE(REPLACE(col, ';My attempts using operation;', ''), ';My attempts using operation', ''), 'attempts using nex;', 'attempts using imex;') FROM mytable;. If you're looking for a general solution to removing the trailing semicolon, you'd require a left/substring with a case statement.