• paul.j.kemna (2/1/2013)


    I don't get what "operator" is in these examples. I would also prefer to not use the splitter function.

    I am to the point where i may have to rely on a a cursor and just parse the text line by line.

    paul.j.kemna (2/1/2013)


    I don't get what "operator" is in these examples. I would also prefer to not use the splitter function.

    I am to the point where i may have to rely on a a cursor and just parse the text line by line.

    Well here is the rub. Not only is a cursor going to perform far worse, you have only 1 row of data so you can't use a cursor anyway. You need to split your text lines into separate rows first.

    This seems to work on your example.

    ;WITH Actions (message) AS

    (

    ;WITH Actions (message) AS

    (

    SELECT '< br>20:32:12 [Rachel] Thank you for contacting Our Company. How may I assist you?< br>< br>20:32:31 [Marina Galofaro] What is the mailing address to mail a check?< br>< br>20:32:49 [Rachel] I''m happy to provide you with the mailing address.< br>< br>20:33:22 [Marina Galofaro] O kay, Thank you.< br>< br>20:33:28 [Rachel] One moment please while I provide a link with directions to mail your payment.< br>< br>20:34:05 [Rachel] Please click <a href="http://company.custhelp.com/app/answers/detail/a_id/1050/kw/payment" target="_blank">here</a> to view how to mail a payment.< br>< br>20:35:07 [Rachel] Is there anything else I can help with, Marina? < br>< br>20:35:56 [Marina Galofaro] No, Thank you!< br>< br>20:36:00 [Marina Galofaro] Session Disconnected< br>'

    )

    ,Transcript(Message) as

    (

    select Item

    from Actions

    cross apply dbo.DelimitedSplit8K(replace(replace(message, '< br>< br>', char(10)), '< br>', ''), char(10))

    )

    ,Operators (username) AS

    (

    SELECT 'Rachel'

    )

    SELECT

    operator = LEFT(operator, CHARINDEX(']', operator)-1)

    ,TextOfMessage = LTRIM(RIGHT(operator, LEN(operator)-CHARINDEX(']', operator)))

    FROM Transcript

    CROSS APPLY

    (

    SELECT SUBSTRING(message, CHARINDEX('[', message)+1, LEN(message)) as operator

    ) a

    LEFT JOIN Operators ON LEFT(operator, CHARINDEX(']', operator)-1) = username

    WHERE username IS NULL

    _______________________________________________________________

    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/