如下是存储过程,不知道哪位大仙能将其转换成SQL语句,多谢!
/*
获取文件最后访问日期
@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
------解决方案--------------------
- SQL code
declare @filepath varchar(4000),declare @filedate varchar(20)declare @obj int,@file intdeclare @fileexists varchar(10)exec sp_oacreate 'Scripting.FileSystemObject',@obj outputexec sp_oamethod @obj,'FileExists',@fileexists output,@filepathif @fileexists='False'begin set @filedate='文件不存在' returnendexec sp_oamethod @obj,'GetFile',@file output,@filepathexec sp_oagetproperty @file,'DateLastAccessed',@filedate outputselect @filepath