Link to home
Start Free TrialLog in
Avatar of JonMny
JonMny

asked on

sql Not in Query not working

I have the following query

select lower(rtrim(SAMAccountName)) as userID
FROM OPENQUERY( ADSI,'SELECT SAMAccountName FROM ''LDAP://...''
WHERE objectCategory = ''Person'' AND objectClass = ''user'' order by
name')  where SAMAccountName not  in (Select rtrim(UserID) as SAMAccountName from employee)


When I run the select from active directory I get 800 distinct records when I run it on employee I get 766 but when I run this one I get zero back. I want to insert records in active directory to the employeee table if they dont already exist.
Avatar of ptjcb
ptjcb
Flag of United States of America image

select lower(rtrim(SAMAccountName)) as userID
FROM OPENQUERY( ADSI,'SELECT SAMAccountName FROM ''LDAP://...''
WHERE objectCategory = ''Person'' AND objectClass = ''user'' order by
name')  
where lower(rtrim(SAMAccountName)) not  in (Select rtrim(UserID) as SAMAccountName from employee)
Avatar of JonMny
JonMny

ASKER

that gives me the same result. zero records
ASKER CERTIFIED SOLUTION
Avatar of JonMny
JonMny

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Closed, 500 points refunded.
Vee_Mod
Community Support Moderator