472,355 Members | 1,844 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,355 software developers and data experts.

function to extract delimited data

I'd need to have a function that allows me to extract 'fields' from
within the string
I.E. (kinda pseudo code)
declare @foo as varchar(100)
set @foo = "Robert*Camarda*123 Main Street"
select EXTRACT(@foo, '*', 2) ; -- would return 'Camarda'
select EXTRACT(@foo, '*', 3) ;-- returns '123 Main Street'
select EXTRACT(@foo, '*', 0) ;-- would return entire string
select EXTRACT(@foo,'*' , 9) ;-- would return null

Extract( string, text delimiter, occurance)
Anyone have something like this as a user defined function in SQL?
TIA
Rob
Mar 11 '08 #1
1 4490
rcamarda (ro**************@gmail.com) writes:
I'd need to have a function that allows me to extract 'fields' from
within the string
I.E. (kinda pseudo code)
declare @foo as varchar(100)
set @foo = "Robert*Camarda*123 Main Street"
select EXTRACT(@foo, '*', 2) ; -- would return 'Camarda'
select EXTRACT(@foo, '*', 3) ;-- returns '123 Main Street'
select EXTRACT(@foo, '*', 0) ;-- would return entire string
select EXTRACT(@foo,'*' , 9) ;-- would return null

Extract( string, text delimiter, occurance)
Anyone have something like this as a user defined function in SQL?
A whole bunch of them here: http://www.sommarskog.se/arrays-in-sql.html.
OK, so none of them returns a specific field from the string,
but several returns a list position to filter on.


--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Mar 11 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Penn Markham | last post by:
Hello all, I am writing a script where I need to use the system() function to call htpasswd. I can do this just fine on the command line...works great (see attached file, test.php). When my...
2
by: ThurstonHowl | last post by:
Hello, my task is the following: Input are tables with fields containing strings where the strings are actually delimited lists. For example, one field could contain 'AB|CD|EF|GH' I've...
5
by: Fresh Air Rider | last post by:
Hello Could anyone please explain how I can pass more than one arguement/parameter value to a function using <asp:linkbutton> or is this a major shortfall of the language ? Consider the...
19
by: Gary Kahrau | last post by:
I want to create a function and can only get half way to my goal. dim sStr as string sStr = Entry(2,"a,b,c,d") ' Sets sStr = "b" Entry(2,sStr) = "B" ' Sets sStr = "a,B,c,d"...
3
by: Lance Hoffmeyer | last post by:
Hey all, I'm new to python. I keep getting an error when running this. I'm sure there is an easy fix but I can't figure it out. What am I doing wrong? How do I fix it? def...
7
by: fool | last post by:
Dear group, Extract the integer value present in a given string. So I tried the following: int main(void) { int val; char *data; data = malloc(sizeof *data); if(data)
0
by: napolpie | last post by:
DISCUSSION IN USER nappie writes: Hello, I'm Peter and I'm new in python codying and I'm using parsying to extract data from one meteo Arpege file. This file is long file and it's composed by...
17
by: Umesh | last post by:
Can anyone do it? ARMY1987- what say?
2
by: someusernamehere | last post by:
Hey, I need to create an application wich extract data from a .csv text (delimited by commas), the problem is that I only need some relevant data, its posssible extract what I want (may be with...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it so the python app could use a http request to get...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
0
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.