I have a string 'I Love India'
I want to write a query that will display o/p in following format--
I
LOVE
INDIA
all in seperate lines
Thanks,
Ankur
The code below will meet your very specific requirement.
Are you looking for a solution that you can utilise for any text string containing spaces?
Chris
SELECT t.[Text]
FROM
(SELECT 1 AS [ID], 'I' AS [TEXT] UNION
SELECT 2, 'LOVE' UNION
SELECT 3, 'INDIA') t
ORDER BY T.[ID]
|||Use a variation of Jen Seussmeyer's SPLIT function, located here:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=326300&SiteID=1
Or, if you are really attempting to simulate an array, check out these resources:
Arrays and Lists in SQL Server
http://www.sommarskog.se/arrays-in-sql.html
http://www.realsqlguy.com/?p=9
http://www.aspfaq.com/2248
http://www.projectdmx.com/tsql/sqlarrays.aspx
http://realsqlguy.com/twiki/bin/view/RealSQLGuy/ParseDelimitedStringToTable
2005- http://omnibuzz-sql.blogspot.com/2006/06/interesting-queries-using-recursive.html
http://solidqualitylearning.com/Blogs/dejan/archive/2004/10/22/200.aspx
No comments:
Post a Comment