SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Need SQL Query
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

mysweet
Starting Member

India
3 Posts

Posted - 04/20/2013 :  01:04:46  Show Profile  Reply with Quote
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

India
52317 Posts

Posted - 04/20/2013 :  02:37:41  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000