将SQL / LDAP查询限制为901行

时间:2015-03-18 11:43:58

标签: sql sql-server tsql ado.net ldap

我在ADO.NET SSIS包中使用了以下LDAP / SQL查询,我试图弄清楚如何将行限制为901:

 SELECT 
       displayName, 
       cn, 
       extensionAttribute5, 
       streetAddress, 
       telephoneNumber, 
       otherTelephone, 
       info, 
       department, 
       company, 
       givenName, 
       mobile, 
       physicalDeliveryOfficeName, 
       facsimileTelephoneNumber, 
       sn, 
       title, 
       mail
 FROM            
       'LDAP://OU=*****,OU=*****,OU=*****,DC=*****,DC=*****,DC=*****'

 WHERE        
       objectCategory = 'Person' AND 
       objectClass = 'User'

1 个答案:

答案 0 :(得分:0)

试试这个:

with x as(
SELECT * FROM OpenQuery ( 
ADSI, 
'SELECT  
  adspath,
  samaccountname    
FROM 
  ''LDAP:// ...''
WHERE 
  objectClass = ''User''
order by samaccountname
') AS tblADSI 
)
select 
      top 901
      adspath,
      samaccountname
 from 
    x