;create table temp2(dir nvarchar(255),depth varchar(255));--
然后把从D盘的website下的所有目录存到temp2中,语句如下:
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
当然也可以把D盘的website下第二个子目录下的所有目录存到temp2中,只需把第二个top 1改为top 2就行了。
现在,我们用同样的方法判断该目录是否为根目录:
and (select count(*) from temp2 where dir<>'user')<(select count(*) from temp2)
如果返回为真,为了确定我们的判断,多测试几个例子,方法上面都讲到了,如果多个例子都返回为真,那么就确定了该目录为WEB根目录。
用以上的方法基本上可以获得WEB根目录,现在我们假设WEB根目录是:D:websitewww
然后,我们就可以备份当前数据库到这个目录下用来下载。备份前我们把temp、temp1、temp2的内容清空,然后C、D、E盘的目录树分别存到temp、temp1、temp2中。
下载完数据库后要记得把三个临时表DROP掉,现在我们在下载的数据库中可以找到所有的目录列表,包括后台管理的目录以及更多信息。 |
|