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
 Retrieve The Value Between Two Characters

Author  Topic 

cnbhold
Starting Member

43 Posts

Posted - 2012-08-24 : 10:43:07
I need away to retrieve the value between an equal sign and a comma.

Sample Data:

GroupName
CN=GroupNameOne,OU=OrganizationalUnit1
CN=GroupNameTwo,OU=OrganizationalUnit1
CN=GroupNameThree,OU=OrganizationalUnit1
CN=GroupNameFour,OU=OrganizationalUnit1
CN=GroupNameFive,OU=OrganizationalUnit1

Desired Results

GroupName
GroupNameOne
GroupNameTwo
GroupNameThree
GroupNameFour
GroupNameFive

Angel

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-08-24 : 10:52:17
Something like this based on your example:
SELECT LEFT(STUFF(GroupName,1,3,''),CHARINDEX(',',GroupName)-4)
If you are trying to query Active Directory, there are other ways - see here for an example: http://sql.dzone.com/news/querying-active-directory-thro
Go to Top of Page

cnbhold
Starting Member

43 Posts

Posted - 2012-08-24 : 10:55:16
Thanks for SQL example which worked great and the web site link!

Angel
Go to Top of Page
   

- Advertisement -