• By the way, I ended up with the following code. Thanks for helping.

    Jan

    CREATE TABLE #tmpADUsers

     (  employeeId varchar(10) NULL,

      SAMAccountName varchar(255) NOT NULL,

      email  varchar(255) NULL)

    GO

    /* AD is limited to send 1000 records in one batch. In an ADO interface you can define this batch size, not in OPENQUERY.

    Because of this limitation, we just loop through the alphabet.

    */

    DECLARE @cmdstr varchar(255)

    DECLARE @nAsciiValue smallint

    DECLARE @sChar char(1)

    SELECT @nAsciiValue = 65

    WHILE @nAsciiValue < 91

     BEGIN

      SELECT @sChar=  CHAR(@nAsciiValue)

      EXEC master..xp_sprintf @cmdstr OUTPUT, 'SELECT employeeId, SAMAccountName, Mail FROM OPENQUERY( ADSI, ''SELECT Mail, SAMAccountName, employeeID FROM ''''LDAP://dc=central,dc=mydomain,dc=int''''WHERE objectCategory = ''''Person'''' AND SAMAccountName = ''''%s*'''''' )', @sChar

            

      INSERT #tmpADUsers

      EXEC( @cmdstr )

      

      SELECT @nAsciiValue = @nAsciiValue + 1

     END

    DROP TABLE #tmpADUsers