zoukankan      html  css  js  c++  java
  • sql判断文件是否存在

    create    proc p_QueryCheckFile
        
    @path nvarchar(1000),
        
    @fname nvarchar(250)
    as

    --检查文件是否已经存在
    if right(@path,1)<>'\' 
        
    set @path=@path+'\'


    if exists (select * 
                
    from sysobjects 
                    
    where type='u'
                        
    and 
                    name 
    = 'temp_xp_fileexist')
        
    begin
            
    drop table temp_xp_fileexist
        
    end
            
    create table temp_xp_fileexist(a bit,b bit,c bit)
    declare @sql nvarchar(1000)
    set @sql=@path+@fname


    insert into temp_xp_fileexist 
        
    exec master..xp_fileexist @sql
    /*
    xp_fileexist 返回的三个列,   分别代表

    文件已存在   文件是目录   父目录已存在   
      -----       -----       ------   
      0               0               1   
    */

    if exists(select 1 from temp_xp_fileexist where a=1)
        
    --文件已经存在
        begin
             
    declare @del nvarchar(200)
                
    select @del = 'del '+@sql 
               
    exec  master..xp_cmdshell  @del 
        
    end
    GO


  • 相关阅读:
    fork 函数 和vfork 函数的区别
    进程时间
    输出子进程状态
    二维字符串数组字典排序
    括号匹配
    队列实现二叉树层序遍历
    二叉查找树
    分块查找
    JS中的className含义
    Java打印温度转换表
  • 原文地址:https://www.cnblogs.com/Bruce_H21/p/797684.html
Copyright © 2011-2022 走看看