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

searching longtext field

Status
Not open for further replies.

cristens

Technical User
Aug 20, 2001
3
0
0
US
I need to be able to pull certain information out of a long text field and shove it into a new table. I thought I should use an on insert trigger, but I'm not sure how I go about searching the longtext field to pull out the information I want. The longtext field contains an XML document and I only want to pull out certain tags. Any help is greatly apreciated.

Cristen
 

You can use the CHARINDEX function to locate the start and end of the string you want to extract. Use the SUBSTRING function to extract the string.

Select
substring(textcol,charindex('xmltag1',textcol), charindex('xmltag2', textcol, charindex('xmltag1',textcol)+1) - charindex('xmltag1',textcol)) As ExtractedText
From tablename
Where charindex('xmltag1', textcol) > 0
And charindex('xmltag2', textcol, charindex('xmltag1', textcol) + 1) > 0 Terry L. Broadbent
faq183-874 contains some tips and ideas for posting questions in these forums. Please review it and comment if you have time.
NOTE: Reference to the FAQ is part of my signature and is not directed at any individual.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top