SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


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


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

Author
Message
Allen Winfree
Allen Winfree
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
Points: 3 Visits: 22
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.
Sean Lange
Sean Lange
One Orange Chip
One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)

Group: General Forum Members
Points: 26046 Visits: 17528
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.

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)
Allen Winfree
Allen Winfree
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
Points: 3 Visits: 22
Thanks Sean for the reply. Okay, let me read through the "Splitter" article.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search