SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Parse text from Right of string
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

murrayb3024
Yak Posting Veteran

79 Posts

Posted - 06/20/2013 :  10:43:29  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

3724 Posts

Posted - 06/20/2013 :  10:47:58  Show Profile  Reply with Quote
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 - 06/20/2013 :  11:09:52  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

3724 Posts

Posted - 06/20/2013 :  14:54:19  Show Profile  Reply with Quote
You are welcome - glad to help.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000