Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Help - Need to parse out some values in the a long text field Expand / Collapse
Author
Message
Posted Wednesday, June 26, 2013 9:40 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, May 8, 2014 7:42 AM
Points: 3, Visits: 19
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.
Post #1467747
Posted Wednesday, June 26, 2013 9:43 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 7:38 AM
Points: 13,062, Visits: 11,893
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 Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1467750
Posted Wednesday, June 26, 2013 9:52 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, May 8, 2014 7:42 AM
Points: 3, Visits: 19
Thanks Sean for the reply. Okay, let me read through the "Splitter" article.
Post #1467754
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse