Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
Hello,I am trying to extract the number from a text string that is sent to us by the client. Unfortunately it is part of the note that is typed in by the users and follows no particular pattern.for example: 14 box 003541903 2whatsup 588(003541903 being the number I am after)This number does not always have the same number of digits and the leading zeros can be trimmed. The most reliable way of doing this would be probably to extract numbers minimum of 5 digits long (please note that position of the number within the text string differs too)Is this even doable?Any help would be much appreciated,Thank you,Kind Regards,Tom
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts
Posted - 2012-11-13 : 07:51:30
It is somewhat messy, but you can do it something like shown below
You are quite welcome :)You may want to test boundary cases such as when there are no characters following the number sequence etc. and make appropriate changes to account for such cases.
Tom85
Starting Member
13 Posts
Posted - 2012-11-13 : 11:03:55
Yeah, It does need some tweaking, I'm just trying to wrap my head around it now (My OCD kicked in, I'm gonna waste another day staring at it, I know it!). The important thing is that you gave me the code I can work with, I spent good few hours building that frustration - I was about to loose it.Thanks again, you're a star!Kind Regards,TomRegards,Tom