What you want to see on DotNetFunda.com ?
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 17924 |  Welcome, Guest!   Register  Login
 Home > Forums > Sql Server > How to extract numeric data ? ...
Jasminej

How to extract numeric data ?

Replies: 7 | Posted by: Jasminej on 7/24/2012 | Category: Sql Server Forums | Views: 365 | Status: [Member] | Points: 10  


I have one table and it has some record...

ItemDescription
----------------------
Vizio0001
RIM0002
Dell0003
Malata0004
eLocity0005

I want to extract the numeric data. my output should should be like
0001
0002
0003
0004
0005

How to do that with simple logic ?

thanks in advance


Reply | Reply with attachment | Alert Moderator

 Responses below this adGet hundreds of .NET Tips and Tricks videos

 Replies

Hadyallam
Hadyallam  
Posted on: 7/24/2012 8:07:47 AM
Level: Starter | Status: [Member] | Points: 25

string StringAfterModification= "";
string num = "0123456789";

foreach (char t in MyString)
{
if (num.Contains(t))
{
StringAfterModification+= t;
}
}

Jasminej, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Hadyallam
Hadyallam  
Posted on: 7/24/2012 8:08:38 AM
Level: Starter | Status: [Member] | Points: 25

also you can use ASCII

Jasminej, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Pandians
Pandians  
Posted on: 7/24/2012 8:12:18 AM
Level: Silver | Status: [Member] [MVP] | Points: 50

Resolved

Check it out!
Select SUBSTRING(ItemDescription,PATINDEX('%[0-9]%',ItemDescription),LEN(ItemDescription)) from <TableName>


Cheers
www.SQLServerbuddy.blogspot.com
iLink Multitech Solutions

Jasminej, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Ranjeet_8
Ranjeet_8  
Posted on: 7/24/2012 8:33:18 AM
Level: Gold | Status: [Member] | Points: 25

Try This.
Select SubString(Column_Name, PatIndex('%[0-9]%', Column_Name), 8000)  From   Table_Name

Jasminej, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Patel28rajendra
Patel28rajendra  
Posted on: 7/24/2012 8:53:42 AM
Level: Starter | Status: [Member] | Points: 25

Hi

try

SELECT RIGHT(ItemDescription, 4)


Regards


R D Patel

Jasminej, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Vuyiswamb
Vuyiswamb  
Posted on: 7/24/2012 9:07:48 AM
Level: NotApplicable | Status: [Member] [MVP] [Administrator] | Points: 25

Questions

Vizio0001 

RIM0002
Dell0003
Malata0004
eLocity0005


First find the occurance of a number and do a substring to get the remaining numbers.


Thank you for posting at Dotnetfunda
[Administrator]

Jasminej, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Jasminej
Jasminej  
Posted on: 7/25/2012 12:41:49 AM
Level: Starter | Status: [Member] | Points: 25

Thank you all!

Jasminej, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Reply - Please login to reply


Click here to login & reply

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/21/2013 11:18:30 AM