• 在SQL Server中取得操作系统文件的最后修改日期 [Z]


    /*
      获取文件最后访问日期
      @filepath   文件路径,如:   c:\1.txt
      @filedate   文件最后访问日期

      调用示例:
      declare   @dt   varchar(20)
      exec   getFileLastAccessDate   'c:\1.txt',@dt   output
      select   @dt
    */
    create   procedure   getFileLastAccessDate
      
    @filepath   varchar(4000),
      
    @filedate   varchar(20)   output
    as
      
    declare   @obj   int,@file   int
      
    declare   @fileexists   varchar(10)
      
    exec   sp_oacreate   'Scripting.FileSystemObject',@obj   output
      
    exec   sp_oamethod   @obj,'FileExists',@fileexists   output,@filepath
      
    if   @fileexists='False'
      
    begin
        
    set   @filedate='文件不存在'
        
    return
      
    end
      
    exec   sp_oamethod   @obj,'GetFile',@file   output,@filepath
      
    exec   sp_oagetproperty   @file,'DateLastAccessed',@filedate   output
    go
    /*
      获取文件最后修改日期
      @filepath   文件路径,如:   c:\1.txt
      @filedate   文件最后修改日期

      调用示例:
      declare   @dt   varchar(20)
      exec   getFileLastModified   'c:\1.txt',@dt   output
      select   @dt
    */
    create procedure getFileLastModified
      
    @filepath varchar(4000),
      
    @filedate varchar(20) output
    as
      
    declare   @obj   int,@file   int
      
    declare   @fileexists   varchar(10)
      
    exec   sp_oacreate   'Scripting.FileSystemObject',@obj   output
      
    exec   sp_oamethod   @obj,'FileExists',@fileexists   output,@filepath
      
    if   @fileexists='False'
      
    begin
        
    set   @filedate='文件不存在'
        
    return
      
    end
      
    exec   sp_oamethod   @obj,'GetFile',@file   output,@filepath
      
    exec   sp_oagetproperty   @file,'DateLastModified',@filedate   output
    go
  • 相关阅读:
    加密算法整理
    NSURLConnection类说明
    ios5 中文键盘高度变高覆盖现有ui问题的解决方案(获取键盘高度的方法)
    "ld: library not found for l...." 问题的解决
    ios5 自定义导航条问题
    objectivec 语言知识点
    JSON
    [转]XCode中修改缺省公司名称/开发人员名称
    [转]iPhone开源项目汇总
    清除SQL 数据库日志 欧阳锋
  • 原文地址:https://www.cnblogs.com/RobotTech/p/1067905.html
Copyright © 2020-2023  润新知