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 |
abul_mohsin
Starting Member
21 Posts |
Posted - 2013-12-19 : 04:07:28
|
DearsNeed help for a select statement.column data : "CN=Doctor John Tom,OU=Migrated Users,DC=ABC,DC=COM"Expected value of CN : "Doctor John Tom"Thanks in advance.Thanks & Best Regard'sAbul Mohsin |
|
Kristen
Test
22859 Posts |
Posted - 2013-12-19 : 04:24:43
|
[code]SELECT SUBSTRING(MyColumn, CHARINDEX('CN=', MyColumn)+3, CHARINDEX(',', SUBSTRING(MyColumn+',', CHARINDEX('CN=', MyColumn), LEN(MyColumn)+1))-1-3 )[/code] |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-12-19 : 04:33:57
|
Is the format consistent always?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
abul_mohsin
Starting Member
21 Posts |
Posted - 2013-12-19 : 04:47:08
|
Yes its always same but with different value of CN.quote: Originally posted by visakh16 Is the format consistent always?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs
Thanks & Best Regard'sAbul Mohsin |
|
|
Kristen
Test
22859 Posts |
Posted - 2013-12-19 : 05:31:59
|
quote: Originally posted by abul_mohsin Yes its always same but with different value of CN.
If CN is guaranteed to ALWAYS be the first entry, and there will ALWAYS be at least a second entry after it, then you could use a more simple method.My code, above, will work if CN is in first, middle, or last position |
|
|
|
|
|
|
|