| 
                
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. 
    
        | 
                
                    | 
                            
                                | Author | Topic |  
                                    | whr2Starting Member
 
 
                                        9 Posts | 
                                            
                                            |  Posted - 2009-04-17 : 10:17:42 
 |  
                                            | I have a field that is being returned in a query that could contain information that looks like this: \FLAG=ADRormachine \FLAG=PPS10ormachine \FLAG=DONOTHING unknownThe information after \FLAG= could be almost anything. I'm trying to figure out how to strip out everything and just have the information after \FLAG=. So in my examples I above I would see this returned:ADRPPS10DONOTHINGSuggestions?Thanks |  |  
                                    | jhocuttConstraint Violating Yak Guru
 
 
                                    385 Posts | 
                                        
                                          |  Posted - 2009-04-17 : 10:28:27 
 |  
                                          | declare @t table( mydata varchar(255))insert into @t select '\FLAG=ADR' union allselect 'machine \FLAG=PPS10' union allselect 'machine \FLAG=DONOTHING unknown'select * from @tselect substring(mydata, charindex('\FLAG=', mydata,  1)+len('\FLAG='), len(mydata)) from @t"God does not play dice" -- Albert Einstein"Not only does God play dice, but he sometimes throws them where they cannot be seen."  --  Stephen Hawking |  
                                          |  |  |  
                                    | madhivananPremature Yak Congratulator
 
 
                                    22864 Posts | 
                                        
                                          |  Posted - 2009-04-17 : 10:28:47 
 |  
                                          | select substring(col,charindex('\FLAG=',col)+6,len(col)) from your_tableMadhivananFailing to plan is Planning to fail |  
                                          |  |  |  
                                    | madhivananPremature Yak Congratulator
 
 
                                    22864 Posts | 
                                        
                                          |  Posted - 2009-04-17 : 10:29:54 
 |  
                                          |  MadhivananFailing to plan is Planning to fail |  
                                          |  |  |  
                                    | whr2Starting Member
 
 
                                    9 Posts | 
                                        
                                          |  Posted - 2009-04-17 : 10:46:12 
 |  
                                          | quote:Thanks, those got me in the ballpark. In my example I'm seeing this where machine \FLAG=DONOTHING unknown, I get a result return of DONOTHING unknown, but I think I can figure that out.Originally posted by madhivanan
 select substring(col,charindex('\FLAG=',col)+6,len(col)) from your_table
 
 |  
                                          |  |  |  
                                |  |  |  |  |  |