SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Is there any function to separate numeric values
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

karthik0805
Starting Member

14 Posts

Posted - 09/28/2012 :  06:39:29  Show Profile  Reply with Quote
Is there any function to separate numeric values and characters in SQL?

for example :

String:'56879port782'

Can we separate the numeric values from above string?
expecting output is : '56879782'

arpana patil
Starting Member

India
24 Posts

Posted - 09/28/2012 :  06:55:56  Show Profile  Reply with Quote
CREATE Function [dbo].[RemoveNonNumericCharacters](@Temp VarChar(1000))
Returns VarChar(1000)
AS
Begin

While PatIndex('%[^0-9]%', @Temp) > 0
Set @Temp = Stuff(@Temp, PatIndex('%[^0-9]%', @Temp), 1, '')

Return @TEmp
End
Go to Top of Page

karthik0805
Starting Member

14 Posts

Posted - 09/28/2012 :  07:22:10  Show Profile  Reply with Quote
Thank you, Arpana!
Go to Top of Page

arpana patil
Starting Member

India
24 Posts

Posted - 09/28/2012 :  07:29:50  Show Profile  Reply with Quote
welcome
Go to Top of Page

madhivanan
Premature Yak Congratulator

India
22742 Posts

Posted - 10/05/2012 :  05:08:22  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
Other techniques http://beyondrelational.com/modules/2/blogs/70/posts/10946/extract-only-numbers-from-a-string-part-3.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
  Previous Topic Topic Next Topic  
 New 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.05 seconds. Powered By: Snitz Forums 2000