473,326 Members | 2,095 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Using SQL Server (T-SQL) to parse text

In MS Access 2000 if I have a String such as:

Column1
Delta CC: 123
Charley CC: 234
Foxtrot CC: 890

and I wanted to extact just the numbers in to a field called CC

I could use this formula in a calculated field:

CC: Mid([Column1],Instr(1,[Column1],"CC")+3,50)

resulting in:

CC
123
234
890
Any idea on what the code should be within a view in SQL Server?

also -- what is a good reference that can help with these types of
problems.

Any help appreciated!

RBollinger

Jul 23 '05 #1
2 7944
[posted and mailed, please reply in news]

robboll (ro*****@hotmail.com) writes:
In MS Access 2000 if I have a String such as:

Column1
Delta CC: 123
Charley CC: 234
Foxtrot CC: 890

and I wanted to extact just the numbers in to a field called CC

I could use this formula in a calculated field:

CC: Mid([Column1],Instr(1,[Column1],"CC")+3,50)

resulting in:

CC
123
234
890
Any idea on what the code should be within a view in SQL Server?

also -- what is a good reference that can help with these types of
problems.


Look up Books Online, Transact-SQL Reference, String Functions.

For the example at hand, you could try:

substring(Column1, charindex('CC:', Column1) + 3, len(Column1))

But I have to look up how charindex works about everytime I use it, so
you better double-check me.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #2

robboll wrote:
In MS Access 2000 if I have a String such as:

Column1
Delta CC: 123
Charley CC: 234
Foxtrot CC: 890

and I wanted to extact just the numbers in to a field called CC

I could use this formula in a calculated field:

CC: Mid([Column1],Instr(1,[Column1],"CC")+3,50)

resulting in:

CC
123
234
890
Any idea on what the code should be within a view in SQL Server?

also -- what is a good reference that can help with these types of
problems.

Any help appreciated!

RBollinger


If all columns are this syntax, you could use the patindex function.

select cast(substring(<col>, patindex('%[0-9]%', <col>), 999) as int)
from <table>

This will convert all strings you have supplied above to numbers.

If there could be numbers before the actual ones you want to strip, use
the reverse function:

select cast(reverse(left(reverse(<col>), patindex('%[0-9] %',
reverse(<col>)))) as int)
from <table>

--
David Rowland
For a good user and performance monitor, check DBMonitor
http://dbmonitor.tripod.com

Jul 23 '05 #3

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

Similar topics

0
by: John M. Lembo | last post by:
I am using Perl to parse a text file and output to another file. The text file has data on Unix virtual memory (vmstat) and I want to delete lines that I don't want and output lines that I want to...
2
by: Rob | last post by:
Hi, In the server explorer in Visual Studio.Net I'm able to design tables, create stored procedures, etc for the SQL 2000 database running locally on my computer. If I add a connection to a remove...
3
by: JP SIngh | last post by:
Hi All I have users who upload files using my application using ASPUPLOAD component. My code uploads the file to a network location and once the upload is finish I display the hyperlink using...
6
by: nate | last post by:
Hello, Does anyone know where I can find an ASP server side script written in JavaScript to parse text fields from a form method='POST' using enctype='multipart/form-data'? I'd also like it to...
2
by: Sacha Korell | last post by:
How would I check for an end of file when parsing a text file using the StreamReader object? I would like to do something like this: '******************************** Dim objStreamReader As...
1
by: Ali | last post by:
hi, I am new to asp.net. I have a question about Marshelling b/w client browser and web server(database). I heared that it is better to minimize going back and forth b/w client browser and the...
5
by: Julien C. | last post by:
Hi all, I have an "EditeItem.aspx" page which lets me edit properties of an "Item". In the OnClick() event of my Save button, I do save Item changes to the database and then I redirect the user...
1
by: Terry Mulvany | last post by:
Grettings, Normally I can use Request.RawUrl to get the 'current' page (amongst many other things). But in the case of using a Server.Transfer but the path from the root of the site . So if...
3
by: MattB | last post by:
Server.MapPath works fine for me in a CodeBehind file, but when I try and move that code to a vb class it doesn't. What do I need to change to make Server.MapPath work from my vb class? Thanks! ...
1
by: Rachel | last post by:
We recently upgraded to ASP.NET 2 AJAX Beta 2 an since we are encountering the following problem: STEPS: 1- navigate to a page containing a UpdatePanel using SERVER.TRANSFER 2- click on a...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.