How can I extract a portion of text from inside a field. I’m using the JobHead.PartDescription field.
I would like to be able to extract the Dim Dwg: shown in bold below.
Trailer Unit
High Fuel, Low Fuel Pre-Alarm
Bonded Neutral
Processed By: Jim 7-25-17
Dim Dwg: ABC-01-SAE-12
AC Diagram: E-A-01234
DC Diagram: E-D-04321
Unfortunately, I cannot simply count the characters since the preceding text varies. I was thinking about chopping it up into smaller pieces then doing a substring at character position.
Something with substring and charindex? Pattern index?
I can use PATINDEX() to identify the start of the word
PATINDEX(’%Dwg:%’, JobHead.PartDescription)
Maybe able to use that information to do my substring.
CHAR(10) is for a new line char and delimits an end of line and not 10 characters. Where your sample data had
At the end of each line there is a CHAR(10) and usually a CHAR(13) on Windows systems one denotes a NEWLINE and the other is CARRIAGE RETURN. These are hidden but part of the actual strings and that is how I am grabbing entire line containing my search string and using the Ice.Entry for the part after the ‘:’
You could replace the string BOAT MFG with your ‘DIM DWG’ or ‘Dim Dwg’ either should work and that will return the drawing number no matter how long it is provided there is an end of line character at the end of its line where your code is using the ‘AC Diagram’ as long as no other data pieces use ‘AC’ before the ‘DIM DWG’ you’ll never get an error…