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 2000 Forums
 Transact-SQL (2000)
 How do I retrieve the rightmost characters

Author  Topic 

savvy95
Starting Member

23 Posts

Posted - 2005-04-08 : 15:30:52
I'm sure others have asked this question, but I can't find the answer. That's why I've turned to the TEAM......

The Situation:
I have a field with a long string:
/o=ORGANIZATION/ou=First Administrative Group/cn=Configuration/cn=Servers/cn=SERVERNAME

The SERVERNAME has a variable length. One server could be named "Superman", and another "AB2"

The Question:
How do I retrieve only the SERVERNAME?

thank you in advance

rfrancisco
Yak Posting Veteran

95 Posts

Posted - 2005-04-08 : 15:35:53
Try this:


DECLARE @v varchar(1000)
SET @v = '/o=ORGANIZATION/ou=First Administrative Group/cn=Configuration/cn=Servers/cn=SERVERNAME'

SELECT RIGHT(@v, CHARINDEX('=', REVERSE(@v)) - 1)
Go to Top of Page

savvy95
Starting Member

23 Posts

Posted - 2005-04-08 : 15:43:28
Perfect. Thanx so much your great.
Go to Top of Page
   

- Advertisement -