sql extract data

How can I capture in SQL only the part that says OU=447 (or whatever number shows up)?  I actually only need the number part.

picture of string
I have this script to give me all the numbers in the string however, I still am not sure how to get the OU number by itself

;WITH T1(number) AS (SELECT 1 UNION ALL SELECT 1),
T2(number)  AS (SELECT 1 FROM T1 AS a cross join T1 as b),
T3(number)  AS (SELECT 1 FROM T2 AS a cross join T2 as b),
T4(number)  AS (SELECT 1 FROM T3 AS a cross join T3 as b),
Nums(number) AS (SELECT ROW_NUMBER() OVER(ORDER BY (SELECT NULL))
from T4)
 
SELECT STUFF(
(SELECT   '' + SUBSTRING(UserDN,Nums.number,1)
FROM Nums
WHERE ISNUMERIC(SUBSTRING(UserDN,Nums.number,1))=1
FOR XML PATH('')),1,0,'') as 'num'
from SSOLogs
mkamp81Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ares KurkluSoftware EngineerCommented:
if that's the only instance where OU= is followed by a numeric value you can simply use:

 UserDN LIKE '%OU=[0-9]%'

and once you retrieve the value if you just want the number you can simply use replace function to replace OU= by empty string.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
SQL

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.