I am trying to reverse string values in a column in SQL Server.
What I am trying to achieve is, when the value of the column is child/parent
, I want to change it to parent/child
when child contains '112'
For example I want to change columns with value Reports/112-Major
to 112-Major/Reports
To start with, I tried to use STRING_SPLIT
and append them like String_Split(ColumnName,'/')[1] + String_Split(ColumnName,'/')[0]
if String_Split(ColumnName,'/')[1] like '%112%'
Most of the examples that I see online have something like
SELECT Value FROM STRING_SPLIT('Lorem/ipsum/dolor/sit/amet.', '/');
But I want to split and then merge based on condition and then update the column
Something like,
update tblTableName
set siteUrl = String_Split(ColumnName,'/')[1] + String_Split(ColumnName,'/')[0]
where `String_Split(ColumnName,'/')[1] like '%112%'
Is there a way to do this in SQL Server?