Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CharIndex help

Status
Not open for further replies.

BHScripter

Technical User
Aug 26, 2002
159
0
0
US
Hi:

I have a column of data in a table which is basically a log file that contains basically just a dump of values that could be in a variety of orders.

I want to pull 8 characters after the value UCODE = '

which looks like UCODE = 'br24hr02'

I need the br24hr02

It will always be in the string with exactly this spacing for this kind of value but it could be in multiple places within the whole string depending on what it is logging.

Thanks in advance.
 
select Field, charindex( 'UCODE = ''', Field) as Location
, case
when charindex( 'UCODE = ''', Field) = 0 then
''
Else
substring(bla, charindex( 'UCODE = ''', Field)+9, 8)
End as List
from Table


Simi
 
Had a typo...

select Field, charindex( 'UCODE = ''', Field) as Location, case
when charindex( 'UCODE = ''', Field) = 0 then '' Else
substring(Field, charindex( 'UCODE = ''', Field)+9, 8)
End as List
from Table

Simi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top