473,781 Members | 2,729 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Parse a numeric string from a field

Hello All,

I'm trying to parse for a numeric string from a column in a table. What
I'm looking for is a numeric string of a fixed length of 8.
The column is a comments field and can contain the numeric string in
any position
Here's an example of the values in the column
1) Fri KX 3-21-98 5:48 P.M. arrival Cxled ATRI #27068935 3-17-98
2) wed.kx10/26 Netrez 95860536
Now I need to parse through these lines and return only the 8 digit
numbers in it
The result set should be
27068935
95860536

This is what I've done so far
Declare @tmp table
(
Comments_Txt varchar(255)
)

Insert into @tmp

select Comments_Txt from Reservation

select * FROM @tmp where Comments_Txt
like ('%[0-9][0-9][0-9][0-9][0-9][0**9]%')

But it returns the entire comments field in the result set. What I need

is a way to return just those 8 digits.

Any Ideas??
Thanks in advance!!!

Jul 23 '05 #1
2 2432
You could use the following:

select substring(comme nts_txt,
patindex('%[0-9][0-9][0-9][0-9][0-9][0***9]%', comments_txt), 8)
from @tmp where Comments_Txt
like ('%[0-9][0-9][0-9][0-9][0-9][0***9]%')

--
David Rowland
dbmonitor.tripo d.com

Jul 23 '05 #2
Thank You very much !!! That was just what I needed.

Jul 23 '05 #3

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

Similar topics

1
9979
by: JuniorLinn | last post by:
Hi there - I would like to share this strip of code with our SQL 2000 DBA community. The code below strips all non-numeric characters from a given string field and rebuilds the string. Very simple, but I had to build it from scratch due the lack of info on this specific matter. I am sure there are better solutions out there, although I will be glad if this script can help anyone. Feel free to modify and comment it back. Regards,
3
4747
by: Ken Bush | last post by:
How can I write an update query that removes part of a field? Like if I have a field with values such as 8/3/68 (a birthday obviously) and I need to put values in a new column but I need everything after and including the final / removed to end up with simply 8/3
3
35104
by: Jon Davis | last post by:
The date string: "Thu, 17 Jul 2003 12:35:18 PST" The problem: // this fails on PST DateTime myDate = DateTime.Parse("Thu, 17 Jul 2003 12:35:18 PST"); Help? Jon
11
3621
by: hoopsho | last post by:
Hi Everyone, I am trying to write a program that does a few things very fast and with efficient use of memory... a) I need to parse a space-delimited file that is really large, upwards fo a million lines. b) I need to store the contents into a unique hash. c) I need to then sort the data on a specific field. d) I need to pull out certain fields and report them to the user.
5
3693
by: Navid Azimi | last post by:
What's the best way to parse a currency string to a decimal given the possibility of multiple currencies? That is, my numeric string can be ($12.00) or -£12.00; in either case I want -12.00 to be returned. I understand that this may be slightly difficult given non-symbol currency strings (F or Kr) but I figured that the CultureInfo should be able to take care of it somehow. The closest solution I came up with, short of iterating through...
5
1961
by: Takeadoe | last post by:
I've got a favor to ask - Consider the following numeric field: 511 6805 3205 403 I need to make 2 new numeric fields from this variable, call it CS
29
2909
by: gs | last post by:
let say I have to deal with various date format and I am give format string from one of the following dd/mm/yyyy mm/dd/yyyy dd/mmm/yyyy mmm/dd/yyyy dd/mm/yy mm/dd/yy dd/mmm/yy mmm/dd/yy
5
5526
by: Mike | last post by:
I use MS SQL EXPRESS DB VS 2005, c# Win Application I have problem "The string is non-numeric" with formula CDbl({pr_DajPonudu;1.KolicinskiPopust})/100 * {@NajamProstora}
7
1622
by: john.ford | last post by:
I want to take a long alpha-numeric string with \n and white-space and place ALL elements of the string (even individual parts of a long white-space) into separate list elements. The most common way I've seen this performed is with the split() function, however I don't believe that it has the power to do what I am looking for. Any suggestions? thanks
0
9639
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10143
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9939
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8964
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6729
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5375
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4040
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3633
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2870
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.