Link to home
Start Free TrialLog in
Avatar of dastaub
dastaubFlag for United States of America

asked on

SQL 2005 T-SQL

I would like to use T-sql to flip a string.

I would like to flip 'green,blue'  to 'blue,green'

i wish to flip the order of two words that are separated by a comma.
ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America 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
SOLUTION
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
Avatar of dastaub

ASKER

below is what worked.

declare @TotalBy as varchar(max)
set @TotalBy = '1FacNNNNNNNNo1,1PDDDDDDoc1'
set @TotalBy = right(@TotalBy,(   len(@TotalBy) - CHARINDEX ( ',' ,@TotalBy))   ) + ',' + left(@TotalBy,CHARINDEX ( ',' ,@TotalBy)-1)
select @TotalBy