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.
| Author |
Topic |
|
Scoby
Starting Member
3 Posts |
Posted - 2008-07-07 : 10:42:38
|
| I'm trying to use a replace statement to strip away the extra info and just leave a persons name. This is what the info looks like.CN=Somename Somename/OU=AAA/O=PDDCN=Somename Somename/OU=AAA/O=PPPCN=Somename Somename/OU=AAA/O=PPPI have a replace statement that removes the CN= section of the information, but i can't get the replace statement to work with a wildcard for the '/OU=AAA/O=PDD' section.This is the update statement i'm using.UPDATE Table SETColName=LTRIM(RTRIM(REPLACE(REPLACE(ColName,'CN=',''),'/%','')))It gives no errors but only replaces the CN= portion of the data. Do wildcards actually work with the replace statement or do i need another approach? |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-07-07 : 10:58:58
|
[code]DECLARE @TABLE TABLE( data varchar(50))INSERT INTO @TABLESELECT 'CN=Somename Somename/OU=AAA/O=PDD' UNION ALLSELECT 'CN=Somename Somename/OU=AAA/O=PPP' UNION ALLSELECT 'CN=Somename Somename/OU=AAA/O=PPP'SELECT *, REPLACE(left(data, CHARINDEX('/', data) - 1), 'CN=', '')FROM @TABLE/*data -------------------------------------------------- -----------------CN=Somename Somename/OU=AAA/O=PDD Somename SomenameCN=Somename Somename/OU=AAA/O=PPP Somename SomenameCN=Somename Somename/OU=AAA/O=PPP Somename Somename(3 row(s) affected)*/[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|