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
 General SQL Server Forums
 New to SQL Server Programming
 Need SQL Query

Author  Topic 

mysweet
Starting Member

3 Posts

Posted - 2013-04-20 : 01:04:46
Hi Team,

I need query to split string into individual characters and each character will display in separate row.

For Example, I have a word like mysweet the output should be
m
y
s
w
e
e
t

I am new to oracle.can you please provide the query for this.

Thanks in Advance

lakshmi Reddy

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-04-20 : 02:37:41
in t-sql you can do like this


DECLARE @Word varchar(100)

SET @Word = 'mysweet'

;With Numbers
(
SELECT 1 AS N
UNION ALL
SELECT N + 1
FROM Numbers
WHERE N + 1 <= LEN(@Word)
)

SELECT SUBSTRING(@Word,N,1)
FROM Numbers
OPTION (MAXRECURSION 0)


Dunno about Oracle. For Oracle related question try in oracle forums like www.dbforums.com

This is MS SQL Server forum

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -