How to extract numeric data ? [Resolved]

Posted by Jasminej under Sql Server on 7/24/2012 | Points: 10 | Views : 1119 | Status : [Member] | Replies : 7
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




Responses

Posted by: Pandians on: 7/24/2012 [Member] [MVP] Silver | Points: 50

Up
0
Down

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. | Alert Moderator

Posted by: Hadyallam on: 7/24/2012 [Member] Starter | Points: 25

Up
0
Down
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. | Alert Moderator

Posted by: Hadyallam on: 7/24/2012 [Member] Starter | Points: 25

Up
0
Down
also you can use ASCII

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

Posted by: Ranjeet_8 on: 7/24/2012 [Member] [MVP] Gold | Points: 25

Up
0
Down
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. | Alert Moderator

Posted by: Patel28rajendra on: 7/24/2012 [Member] Starter | Points: 25

Up
0
Down
Hi

try

SELECT RIGHT(ItemDescription, 4)


Regards


R D Patel

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

Posted by: Vuyiswamb on: 7/24/2012 [Member] [MVP] [Administrator] NotApplicable | Points: 25

Up
0
Down
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. | Alert Moderator

Posted by: Jasminej on: 7/25/2012 [Member] Starter | Points: 25

Up
0
Down
Thank you all!

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

Login to post response