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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extract information between Characters

Status
Not open for further replies.

NavMen

Vendor
Jul 6, 2004
35
NL

Hi,

I’m trying to extract some information from a stored message in the SQL database, the message looks like:

Info –I : Message Text [windows event xxx]

I like to extract the information between the “:” and “[“ the query I created is as follows:

Select substring(message,9,500) as 'Message' from SysMessage

It works well if the info before the “:” is 9 characters, I don’t know how to fix this problem. The Message Text is variable in size.

All help is welcome.

Thanks,

J
 
Can't test this, but something like this should be close

select substring(ltrim(rtrim(message)),charindex(':',message)-1,right(charindex('[',message))
from table

You can play around with it anyway to get your desired result

Tim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top