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 2008 Forums
 Transact-SQL (2008)
 trying to parse a text field

Author  Topic 

lmayer4
Starting Member

33 Posts

Posted - 2011-10-04 : 16:18:55
Afternoon,

I'm trying to parse a text field. I have this kind of data:

407339  1pc  [HAHNS - 10/4/2011 2:51:53 PM]    410710  4pcs  [HAHNS - 10/4/2011 2:52:09 PM]]


I need to grab all instances of the jobs, in this case 407339 and 410710.

I have this which grabs the first one:


substring(mr.Note_Text,charindex(' ',mr.Note_Text)-charindex(' ',mr.Note_Text),charindex(' ',mr.Note_Text))


My question is how do get all the instances of it?

Thanks

Laura

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-10-05 : 00:33:11
whats the rule for you?will all numeric data coming in a string be job numbers?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

lmayer4
Starting Member

33 Posts

Posted - 2011-10-05 : 07:56:58
Thats the hard part, they put them in like 407339-1 so there could be a dash or a star in there.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-10-05 : 07:58:45
so can we assume anything without text data be job numbers?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -