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 2000 Forums
 Transact-SQL (2000)
 Reshuffle the string using SQL Server.

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-07-01 : 07:33:34
Raj writes "Hi Team,
I want to reshuffle the string using SQL Server. is there any way to do it please let know.

Ex: string variable myY="RAJA"
Output should be "JRAA" or "AJAR" like that..

any help would be really appreciated.

Thanks,
-Raj."

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2003-07-01 : 08:01:56

declare
@raj varchar(10),
@raj_shuffle varchar(10)
select
@raj = 'JRAA'

select
@raj_shuffle = coalesce(@raj_shuffle+'','') + a
from
(select top 100 percent
a
from
(select
substring(@raj,n,1) a
from
(select 1 as n union select 2 union select 3 union
select 4 union select 5 union select 6 union select 7 union
select 8 union select 9 union select 10) n
where
datalength(@raj)>=n.n) a
order by newid()) a

select
@raj_shuffle

 


Jay White
{0}
Go to Top of Page
   

- Advertisement -