and (select count(*) from temp where depth=1 and dir not in
('Documents and Settings','Program Files','RECYCLER','System VolumeInformation',
'WINDOWS','CAConfig','wmpub',
'Microsoft UAM 卷'))>=数字(数字=0、1、2、3...)
declare @dirname varchar(255);set @dirname='
d:\'+(select top 1 dir from (select top 1 dir from temp where depth=1 and dir not in('Documents and Settings',
'Program Files','RECYCLER',
'System VolumeInformation','WINDOWS',
'CAConfig','wmpub',
'Microsoft UAM 卷') order by dir desc)T order by dir);
insert into temp1 exec master.dbo.xp_dirtree @dirname
and (select count(*) from temp1 where dir<>'user')<(select count(*) from temp1) 假如前往为真,暗示根目次能够在此子目次下,记住要多测试几个例子,假如都前往为假,则标明WEB根目次不在此目次下,然后咱们在用一样的办法来取得D盘第2、3...个子目次下的一切目次列表,来判别WEB根目次是不是在其下。然而,要注重,用xp_dirtree前必定要把temp1表中的内容删除。
declare @dirname varchar(255);set @dirname='d:\website\'
+(select top 1 dir from (select top 1 dir from temp1 where depth=1 and dir not in('Documents and Settings',
'Program Files','RECYCLER',
'System VolumeInformation','WINDOWS','CAConfig',
'wmpub','Microsoft UAM 卷') order by dir desc)T order by dir);
insert into temp2 exec master.dbo.xp_dirtree @dirname