Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 reverse non-english string

Author  Topic 

collie
Constraint Violating Yak Guru

400 Posts

Posted - 2013-09-29 : 13:56:53
Hi,

I have a string in Hebrew that is reversed such as 'tac god (435)'
I want the result to be 'cat dog (435)'
I want it to reverse only the chars and not the numbers.

How can this be done?

Thanks

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-09-29 : 17:07:51
If you can find a consistent separator, then you can do like shown below. In the example below, I am using '(' as the separator. It needs a little refinement - the space before the '(' is also part of the reverse in this example:
declare @x varchar(32) = 'tac god (435)';
select reverse(left(@x,charindex('(',@x+'(')-1))
+ stuff(@x,1,charindex('(',@x+'(')-1,'');
Go to Top of Page
   

- Advertisement -