Help - Need to parse out some values in the a long text field

  • Hello all, i have the following example(s) of values in a varchar field, but need to parse out specific attributes for analysis.

    Here are two examples of the data;

    12/15/2012 19:41:05 : CustList : ReportSubmit : my region code = US, my segment number = 3, my main terr number = 53 - John Smith (802313)

    12/15/2012 19:45:58 : Summary : my region code = US, my segment number = 0, my main terr number = 0 - Scooter Brown(98513) - (Impersonated, by: Casper Ghost (883599))

    In the first, i need to parse the date "12/15/2012", then "CustList" between the colons, and last "John Smith(802313)"

    In the second example, same attributes "12/15/2012", then "Summary" between the colons, then "Scooter Brown(98513)"

    , but need to add "(Impersonated, by: Casper Ghost (883599))"

    any way this can be done? The dataset contains these two examples throughout, i could get by with running two sql statements, one for the true user (first example), then run a second to get the additional field for impersonatiton.

    Any help would be greatly appreciated.

  • Hi and welcome to the forums. In order to help we will need a few things:

    1. Sample DDL in the form of CREATE TABLE statements

    2. Sample data in the form of INSERT INTO statements

    3. Expected results based on the sample data

    Please take a few minutes and read the first article in my signature for best practices when posting questions.

    You might be able to leverage the code by following the link in my signature about splitting strings.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/

  • Thanks Sean for the reply. Okay, let me read through the "Splitter" article.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply