Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Find Values from String in a Single Cell

Author  Topic 

robcole
Starting Member

2 Posts

Posted - 2014-01-10 : 05:20:48
Hello,

Apologies for the lack of understanding as I'm fairly new to this. Basically I have a program which feeds back information to a table within my database. The annoying thing is that only 1 of the table cells has all of the information I need so essentially I have a large string of data I need to retrieve values from.

I retrieve my cell with a simple select details from alerts where ID = (alert number)

The results I have are as follows:

[INFO] Dashboard Output Information:

[LastUpdated]
Time=09:59
[LastProcessed]
LastProcessed=*2911
Updated=09:59
[LastReceived]
LastReceived=#10
Updated=09:59


As you can see I have a list (its larger but this is a sample), the only thing I need are the values for each section so for last processed i want the 2911 so I can use it on my dashboard and the last received I want the 10 for that section.

I have read about using substrings but am really not sure where to start and how I'd go about getting these values to then use elsewhere?

Any help would be greatly appreciated.

Thanks.

Rob.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2014-01-10 : 06:24:06
assuming there will be only one instance of lastprocessed within one row's column value you can do this

SELECT LEFT(STUFF(Column,1,PATINDEX('%LastProcessed=%',Column + 'LastProcessed=')+14,''),PATINDEX('%[A-Za-z]%',STUFF(Column,1,PATINDEX('%LastProcessed=%',Column + 'LastProcessed=')+14,''))-1) FROM Table


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

robcole
Starting Member

2 Posts

Posted - 2014-01-10 : 06:59:05
Cool thanks very much that seems to work :)

Much appreciated!
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2014-01-10 : 07:06:08
welcome

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -