Link to home
Start Free TrialLog in
Avatar of Robb Hill
Robb HillFlag for United States of America

asked on

SQL to get values from a string and make do some logic

I have a sql server db table that is a log table.

There are many logs in this table.

I need to get only the logs that refer to a specific process id.

In short this process ID is hanging on my server....I am trying to determine when it last was noted in the system log..and then by using the time that log was created create a math routine to determine how long it has been running.  That would be determine something like this:  Each time the log is noted in the sytsem log that would mean a new one had been started...else if there had been no mention of it again ...all the time accumulatead since then would be how long its been running.

Also the last occurence of it should also indicate which version of this process id is the one on the system that has been running.



The table has a column called data:  This is text field.  you might find the following  Process Id:  XXXX where XXXX would be 4 numbers in the text field.  I believe the process Id can be more than 4.

There is a dcreated field which is the datetime to the second. 2014-02-04 08:20:51.370

So I would want the last occurence in the log table in which data has the  Process Id: 1234 and how long the last run was reported.    

There will be other items out of this data field I will want to pull ...and other columns in the table...but this is the crux of the query for me at this time...I tried like comparison and compare and they are not working..

I guess I need some charindex /substring method...and not sure how to put that together.


Thanks,
ASKER CERTIFIED SOLUTION
Avatar of Zberteoc
Zberteoc
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
@Robb Hill

If it was you who gave us the thumb up please don't forget to award the points. You can split between people who answered. That is if our solutions satisfy your question.

Thank you.
Avatar of Robb Hill

ASKER

I am still testing...I will get back...sorry for the delay..I got pulled a different direction
Thanks