zoukankan      html  css  js  c++  java
  • 在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
  • 相关阅读:
    JavaScript 的数据类型及其检测
    编写JavaScript 代码的5个小技巧
    canvas标签的基本用法
    析构函数的调用------新标准c++程序设计
    类型转换构造函数 及使用explicit避免类型自动转换------新标准c++程序设计
    c++小知识
    this指针------新标准c++程序设计
    类的互相包含------新标准c++程序设计
    封闭类------新标准c++程序设计
    c++内存模型------计算机系统核心概念及软硬件实现
  • 原文地址:https://www.cnblogs.com/RobotTech/p/1067905.html
Copyright © 2011-2022 走看看