• Vinny & Newbie,

    Thanks, but I knew this. My question is: how can we do this paging from the OPENQUERY function?

    In a vb script (or for that matter any language that uses ADO), we can write something like that:

     objCommand.CommandText = _

     "<;(objectCategory=user">LDAP://dc=Central,dc=mydomain,dc=int>;(objectCategory=user)" & _

     ";distinguishedName,Name,sAMAccountName,primaryGroupID,memberOf,canonicalName,Mail,telephoneNumber;subtree"

    objCommand.Properties("Page Size") = 50

    This tells AD to send batches with 50 records at one time. But where can I put this parameter in the SQL syntax? The following doesn't work:

    SELECT employeeId, SAMAccountName, Mail

     FROM OPENQUERY( ADSI, 'SELECT Mail, SAMAccountName, employeeID FROM 'LDAP://dc=central,dc=mydomain,dc=int''WHERE objectCategory = ''Person'';''Page Size''=50' ) 

    I can partition (not page!) the query like this:

    ... FROM OPENQUERY( ADSI, 'SELECT Mail, SAMAccountName, employeeID FROM ''LDAP://dc=central,dc=mydomain,dc=int''WHERE objectCategory = ''Person'' AND SAMAccountName = ''A*''' )

    and ask for A,B,C, ... , Z. But I prefer the paging attribute, and would like to know how to submit it.

    Many thanks,

    Jan