• yes, it's still not working. I really don't have a clue about how to solve.

    Error is

    Msg 102, Level 15, State 1, Line 5

    Incorrect syntax near 'SELECT * FROM OPENQUERY (

    ADSI,

    'SELECT givenname ,

    sn,

    displayname,

    samaccountname,

    telephonenumber,

    mail,

    department,

    '.

    Here's how it looks without variable substitution, and it returns rows:

    SELECT * FROM OPENQUERY (

    ADSI,

    'SELECT givenname ,

    sn,

    displayname,

    samaccountname,

    telephonenumber,

    mail,

    department,

    title

    FROM ''LDAP://redmond.corp.microsoft.com''

    WHERE

    objectClass = ''USER''

    and objectCategory = ''person''

    and displayName = ''Sanjay*''')

    --Quote me