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


  • 相关阅读:
    图像滤波与OpenCV中的图像平滑处理
    OpenCV创建轨迹条,图片像素的访问
    模板类和友元的总结和实例验证
    C++中运算符重载
    C++之Stack模板类
    C++中explicit关键字的作用
    #ifdef-#endif的作用及其使用技巧
    ZOJ 3170 Friends
    ZOJ 3713 In 7-bit
    HDU 1421 搬寝室
  • 原文地址:https://www.cnblogs.com/Bruce_H21/p/797684.html
Copyright © 2011-2022 走看看