SQLTeam.com | Weblogs | Forums

Active Directory to update sql table


I am attempting to update a sql table from an open query of active directory.
This throws an incorrect syntax error on "as tblAdsi"

update adAttrib
set adAttrib.telephoneNumber = tblADSI.telephoneNumber, adAttrib.facsimileTelephoneNumber = tblADSI.facsimileTelephoneNumber, adAttrib.employeeID = tblADSI.employeeID,
adAttrib.extensionAttribute1 = tblADSI.extensionAttribute1, adAttrib.l = tblADSI.l, adAttrib.department = tblADSI.department, adAttrib.mobile = tblADSI.mobile, adAttrib.mail = tblADSI.mail,
adAttrib.sAMAccountName = tblADSI.sAMAcountname, adAttrib.givenname tblADSI.givenname, adAttrib.sn = tblADSI.sn, adAttrib.displayName = tblADSI.displayName
from adAttributes2 adAttrib, (SELECT *
'SELECT telephoneNumber, mail, mobile, facsimileTelephoneNumber, department, physicalDeliveryOfficeName, givenname, sAMAccountName, displayName, employeeID
FROM ''LDAP://DC=rrd,DC=gradw,DC=tryf''
WHERE objectCategory = ''Person'' AND
objectClass = ''User''')
where mail is not null and givenname is not null and employeeID is not null) tblADSI
where adAttrib.employeeid = tblADSI.employeeid

My searches say that the syntax should be correct?


One of the problems is that you have an equal sign missing on the quoted line, so it should be something like

adAttrib.sAMAccountName = tblADSI.sAMAcountname, adAttrib.givenname = tblADSI.givenname, adAttrib.sn = 

Since I am not able to run the query, I don't know if there are other problems.