Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Other SQL Server Topics (2005)
 numeric data in varchar field
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Joetaniarto00
Starting Member

Indonesia
12 Posts

Posted - 11/20/2014 :  04:12:32  Show Profile  Reply with Quote
Hi,
I have some record as :
Duplex 500 GR
Black Papper 200 GR
Magic Paper 50 GR

I need to take the number information of those data. so it can resulting
500,200,50

Please Help..

Thx

gbritton
Flowing Fount of Yak Knowledge

2780 Posts

Posted - 11/20/2014 :  13:41:26  Show Profile  Reply with Quote
YOu can use the function discussed here:
http://www.sqlservercentral.com/articles/String+Manipulation/94365/
Go to Top of Page

MuralikrishnaVeera
Posting Yak Master

India
129 Posts

Posted - 12/01/2014 :  06:37:41  Show Profile  Reply with Quote
use this

SELECT STUFF(
(SELECT ','+SUBSTRING(a.Col,PATINDEX('%[0-9]%',a.Col),LEN(a.col)-PATINDEX('%[0-9] %',a.Col)) FROM 
(
SELECT 'Duplex 500 GR' AS Col
UNION ALL
select 'Black Papper 200 GR'
UNION ALL
SELECT 'Magic Paper 50 GR'
) a  FOR XML PATH('')),1,1,'')


---------------
Murali Krishna

You live only once ..If you do it right once is enough.......
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000