Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reverse values in a string in T-SQL

Using T-SQL, I'm trying to find the easiest way to make:

"abc.def.ghi/jkl" become "abc/def/ghi.jkl"?

Basically switch the . and /

Thank you

like image 635
Neo302 Avatar asked Dec 29 '22 06:12

Neo302


1 Answers

One way

select replace(replace(replace('abc.def.ghi/jkl','/','-'),'.','/'),'-','.')

you need to use an intermediate step, I chose the - symbol, choose something which won't exist in your string

like image 125
SQLMenace Avatar answered Dec 30 '22 19:12

SQLMenace