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

 All Forums
 SQL Server 2005 Forums
 Other SQL Server Topics (2005)
 numeric data in varchar field

Author  Topic 

Joetaniarto00
Starting Member

12 Posts

Posted - 2014-11-20 : 04:12:32
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
Master Smack Fu Yak Hacker

2780 Posts

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

MuralikrishnaVeera
Posting Yak Master

129 Posts

Posted - 2014-12-01 : 06:37:41
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
   

- Advertisement -