Community FAQ
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
michaelwhite
Engaged Sweeper
When I add tblADComputers.OU into a report, it prints the entire OU. Is there a way to have it only print the lowest level OU?

Ex:

Instead of printing `OU=WebServers,OU=Servers,OU=Computers,DC=EXAMPLE,DC=COM`

Just print `OU=WebServers`

Or even just `WebServers`
1 REPLY 1
RCorbeil
Honored Sweeper II
Take a look at the T-SQL string functions. You can use CharIndex() to check for the presence of a comma and, if present, return a truncated string using Left(), something like
CASE
WHEN CharIndex(',', fullOU) > 0
THEN Left(fullOU, CharIndex(',', fullOU)-1)
ELSE fullOU
END AS lowOU

The simplest way to drop the "OU=" would probably be to wrap the CASE in a Replace().

Reports & Analytics

Ask about reports you're interested in and share reports you've created. Subscribe to receive daily updates of reports shared in the Community.

New to Lansweeper?

Try Lansweeper For Free

Experience Lansweeper with your own data.
Sign up now for a 14-day free trial.

Try Now