Using LEFT function in dynamic SQL call to ADSI
Posted on 2010-11-29
I have a linked sever to AD which works fine except I'm trying to query AD regarding all user whose e-mail address ends in 'manager'. When I do this I get the error, Msg 7321, Level 16, State 2, Line 1
An error occurred while preparing the query "SELECT EmployeeNumber,
WHERE objectCategory = 'Person'
AND objectClass = 'user'
AND LEFT(mail,7) = 'manager'" for execution against OLE DB provider "ADSDSOOBJECT" for linked server "ADSI".
You can see the code in the error. If i remove the line that says, AND LEFT(mail,7) = 'manager' I Don't get the error. My assumption is there is a problem with using things like the LEFT function. I also tried it using the LIKE function with the same results. Any assistance would be greatly appreciated.