Link to home
Start Free TrialLog in
Avatar of blossompark
blossomparkFlag for Ireland

asked on

Reversing variable sized column data in a sql server 2005 table column

Hi,
     I have a column in a table of approx 10,000 rows which currently displays typically as shown below

Office/Users/Partners
Safety Users/LegacyOffice/Users/Partners
ECG /linen/ LegacyOffice/Users/Partners


I want to update the column to display as below

Partners/Users/Office
Partners/Users/LegacyOffice/Users/SafetyUsers
Partners/Users/LegacyOffice/linen/ECG

The question has been previously  addressed by sdstuber in this question
https://www.experts-exchange.com/questions/27411842/Returning-column-data-in-a-different-order-in-sql-server-2005.html
The difference here is that the number of ‘elements’ in each column field may vary…
Any guidance appreciated…thanks
ASKER CERTIFIED SOLUTION
Avatar of sachitjain
sachitjain
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You just need to call it like this

update <tableName> set <ColName>=dbo.ReverseString(<ColName>)

I tested it over following sample code and succeeded
declare @str as varchar(100), @str2 as varchar(max)
set @str = N'Str1/Str2/Str3/Str4/Str6'
select @str2 = dbo.ReverseString(@str)
print @str2
Avatar of blossompark

ASKER

Hi sachitjain:
thanks for your response...will implement and update you with results
SOLUTION
Avatar of Lowfatspread
Lowfatspread
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi  Lowfatspread,
thanks for the input...
yes sachitjain solution is returning unexpected results....
will implement yours and update later
Hi Lowfatspread,
                               I altered sachitjain's code as per your comment and it works fine now...i havent implemented your "stuff" code as sachitjain's is working fine...
thank you both for your help....