→ The Lansweeper Customer Excellence Awards 2024 - Submit Your Project Now! Learn More & Enter Here
‎05-28-2018 03:38 PM
‎05-28-2018 03:55 PM
Where (tblADusers.EmployeeID Like '' And tblADusers.Company = 'Company' And
tblADusers.Description = 'User Account') Or
(tblADusers.EmployeeID Is Null And tblADusers.Company = 'Company' And
tblADusers.Description = 'User Account')
‎05-30-2018 07:44 AM
Charles.X wrote:
Looking at your where clause I can see the problem.
You're basically displaying two groups of users in your query:This means that if a user has NULL for EmployeeID, it will be displayed regardless of any other fields.
- EmployeeID is empty, company is 'company' and description is 'User Account'
- EmployeeID is NULL
I would use the following for your situation:Where (tblADusers.EmployeeID Like '' And tblADusers.Company = 'Company' And
tblADusers.Description = 'User Account') Or
(tblADusers.EmployeeID Is Null And tblADusers.Company = 'Company' And
tblADusers.Description = 'User Account')
Edit: Seems like you figured it out while I was posting 😉
‎05-28-2018 03:44 PM
mjbliss wrote:
Hi,
All my user accounts in AD have the description "User Account" set, this is to differentiate them from Consulting Accounts and Service Accounts, they also have "Company" populated under the Company field.
I'm trying to create a query that lets me know which accounts do not have Employee ID populated, I thought the below query would do the trick but the results still show users that have something other than "User Account" in the description field.
The filtering of users that DO HAVE employee ID populated works as expected.
Any reason why the And tblADusers.Description = 'User Account') doesn't seems to work?
Select Top 1000000 tblADusers.Username,
tblADusers.Userdomain,
tblADusers.Office,
tblADusers.EmployeeID,
tblADusers.Company,
tblADusers.Description
From tblADusers
Where (tblADusers.EmployeeID Like '' And tblADusers.Company = 'Company' And
tblADusers.Description = 'User Account') Or
(tblADusers.EmployeeID Is Null)
Experience Lansweeper with your own data. Sign up now for a 14-day free trial.
Try Now