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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Parse text from Right of string

Author  Topic 

murrayb3024
Yak Posting Veteran

79 Posts

Posted - 2013-06-20 : 10:43:29
We have a field in our database that is a really long string of data. I just want to parse from the right what is between 2 parens on the end. The lengths are not always the same I just need that end info

Built inbound TCP connection xxxxxx for outside:xxxxxxx (xxxxxx/xxx) to inside:xxxxxxx/xxxx (xxxxxx/xxxx) (DATAINEED)
Built inbound TCP connection 12343 for outside:xxxxxxx xxxxxxx/xxxx (xxxxxx/xxyyy) (DATAINEED)

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-06-20 : 10:47:58
See the example below:
DECLARE @x VARCHAR(256) = 'xxxxxxx (xxxxxx/xxx) to inside:xxxxxxx/xxxx (xxxxxx/xxxx) (DATAINEED)';
SELECT REVERSE(STUFF(REVERSE(@x),CHARINDEX('(',REVERSE(@x))+1,LEN(@x),''))
Go to Top of Page

murrayb3024
Yak Posting Veteran

79 Posts

Posted - 2013-06-20 : 11:09:52
quote:
Originally posted by James K

See the example below:
DECLARE @x VARCHAR(256) = 'xxxxxxx (xxxxxx/xxx) to inside:xxxxxxx/xxxx (xxxxxx/xxxx) (DATAINEED)';
SELECT REVERSE(STUFF(REVERSE(@x),CHARINDEX('(',REVERSE(@x))+1,LEN(@x),''))




Thanks James!
Go to Top of Page

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-06-20 : 14:54:19
You are welcome - glad to help.
Go to Top of Page
   

- Advertisement -