| 网站首页 | 新闻中心 | 系统安全 | 网络安全 | 安全技术 | 下载中心 | 安全365社区 |
安全365
收藏本站
设为首页
会员登录:
站内搜索: 新闻中心 系统安全 网络安全 安全技术 下载中心
| 网络安全首页 | 信道安全 | 设备安全 | 协议安全 | Web安全 |
xp_dirtree快速查找SQL语句
xp_dirtree快速查找WEB目录SQL语句
作者:红狼 文章来源:互联网 点击数: 更新时间:2008-5-8 8:44:08

  查找文件的语句

  CODE:

  drop table tmp;

  create table tmp

  (

  [id] [int] IDENTITY (1,1) NOT NULL,

  [name] [nvarchar] (300) NOT NULL,

  [depth] [int] NOT NULL,

  [isfile] [nvarchar] (50) NULL

  );

  declare @id int, @depth int, @root nvarchar(300), @name nvarchar(300)

  set @root='f:\usr\' -- Start root

  set @name='cmd.exe' -- Find file

  insert into tmp exec master..xp_dirtree @root,0,1--

  set @id=(select top 1 id from tmp where isfile=1 and name=@name)

  set @depth=(select top 1 depth from tmp where isfile=1 and name=@name)

  while @depth<>1

  begin

  set @id=(select top 1 id from tmp where isfile=0 and id<@id and depth=(@depth-1) order by id desc)

  set @depth=(select depth from tmp where id=@id)

  set @name=(select name from tmp where id=@id)+'\'+@name

  end

  update tmp set name=@root+@name where id=1

  select name from tmp where id=1

  查找目录的语句

  CODE:

  drop table tmp;

  create table tmp

  (

  [id] [int] IDENTITY (1,1) NOT NULL,

  [name] [nvarchar] (300) NOT NULL,

  [depth] [int] NOT NULL

  );

  declare @id int, @depth int, @root nvarchar(300), @name nvarchar(300)

  set @root='f:\usr\' -- Start root

  set @name='donggeer' -- directory to find

  insert into tmp exec master..xp_dirtree @root,0,0

  set @id=(select top 1 id from tmp where name=@name)

  set @depth=(select top 1 depth from tmp where name=@name)

  while @depth<>1

  begin

  set @id=(select top 1 id from tmp where id<@id and depth=(@depth-1) order by id desc)

  set @depth=(select depth from tmp where id=@id)

  set @name=(select name from tmp where id=@id)+'\'+@name

  end update tmp set name=@root+@name where id=1

  select name from tmp where id=1

文章录入:小张    责任编辑:小张 
  • 上一篇文章:

  • 下一篇文章: 没有了
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
     
     
     
    没有相关文章
    站长邮箱:webmaster@anquan365.com
    联系电话:86-10-67634029 点击这里给我发消息

    Copyright © 2006-2008 www.anquan365.com 北京华安普特网络科技有限公司 版权所有