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.
select lower(rtrim(SAMAccountName
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.
ASKER
that gives me the same result. zero records
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Closed, 500 points refunded.
Vee_Mod
Community Support Moderator
Vee_Mod
Community Support Moderator
FROM OPENQUERY( ADSI,'SELECT SAMAccountName FROM ''LDAP://...''
WHERE objectCategory = ''Person'' AND objectClass = ''user'' order by
name')
where lower(rtrim(SAMAccountName